mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
For container bridging, implement a '_bridge<T>' function that converts a Swift value to AnyObject using a runtime check for its _ObjCBridgeable conformance, crashing if one doesn't exist. Swift SVN r14645
15 lines
201 B
Swift
15 lines
201 B
Swift
// RUN: %target-run-simple-swift | FileCheck %s
|
|
|
|
class C {}
|
|
|
|
struct Foo: _ObjCBridgeable {
|
|
func _bridge() -> AnyObject {
|
|
return C()
|
|
}
|
|
}
|
|
|
|
// CHECK: ok
|
|
if _bridge(Foo()) as C {
|
|
println("ok")
|
|
}
|