mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
With this, we're correctly lowering the dynamic_method_br instruction to IR, which allows us to query the existence of an instance method on a value of type DynamicLookup and, if it's there, call it via the closure stored in the optional. Part of <rdar://problem/14397505>. Swift SVN r8205
22 lines
398 B
Swift
22 lines
398 B
Swift
// RUN: %swift -i %s | FileCheck %s
|
|
|
|
class X {
|
|
func [objc] f() { println("X.f()") }
|
|
}
|
|
|
|
class Y { }
|
|
|
|
func test_dynamic_lookup_f(obj : DynamicLookup) {
|
|
var of = obj.f
|
|
if of {
|
|
of.get()()
|
|
} else {
|
|
print("Object does not respond to the selector \"f\".\n")
|
|
}
|
|
}
|
|
|
|
// CHECK: X.f()
|
|
test_dynamic_lookup_f(X())
|
|
// CHECK: Object does not respond to the selector "f"
|
|
test_dynamic_lookup_f(Y())
|