Files
swift-mirror/test/Interpreter/dynamic_lookup.swift
Doug Gregor c2c367b12a Pass the right selector to swift_objcRespondsToSelector().
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
2013-09-13 17:12:32 +00:00

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())