Files
swift-mirror/test/FixCode/fixits-apply-objc.swift.result
Doug Gregor e97ab635ea [Constraint solver] Separate bridging conversions from other conversions.
Previously, bridging conversions were handled as a form of "explicit
conversion" that was treated along the same path as normal
conversions in matchTypes(). Historically, this made some
sense---bridging was just another form of conversion---however, Swift
now separates out bridging into a different kind of conversion that is
available only via an explicit "as". This change accomplishes a few
things:

* Improves type inference around "as" coercions. We were incorrectly
  inferring type variables of the "x" in "x as T" in cases where a
  bridging conversion was expected, which cause some type inference
  failures (e.g., the SR-3319 regression).

* Detangles checking for bridging conversions from other conversions,
  so it's easier to isolate when we're applying a bridging
  conversion.

* Explicitly handle optionals when dealing with bridging conversions,
  addressing a number of problems with incorrect diagnostics, e.g.,
  complains about "unrelated type" cast failures that would succeed at
  runtime.

Addresses rdar://problem/29496775 / SR-3319 / SR-2365.
2016-12-21 13:46:14 -08:00

32 lines
761 B
Plaintext

// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-objc-attr-requires-foundation-module -typecheck %s -emit-fixits-path %t.remap
// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
import ObjectiveC
// REQUIRES: objc_interop
@objc class Selectors {
func takeSel(_: Selector) {}
func mySel() {}
func test() {
takeSel(#selector(Selectors.mySel))
takeSel(#selector(Selectors.mySel))
}
}
func foo(an : Any) {
let a1 : AnyObject
a1 = an as AnyObject
let a2 : AnyObject?
a2 = an as AnyObject
let a3 : AnyObject!
a3 = an as AnyObject
}
func foo1(_ an : Any) {
let obj: AnyObject = an as AnyObject
}
func foo2(_ messageData: Any?) -> AnyObject? {
return messageData as AnyObject
}