Skip to content

Commit ad01750

Browse files
committed
Some executable tests for unbound references through AnyObject
1 parent c9c5fe2 commit ad01750

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/Interpreter/dynamic_lookup.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ func test_dynamic_lookup_f(_ obj: AnyObject) {
3939
}
4040
}
4141

42+
func test_dynamic_lookup_f_unbound(_ obj: AnyObject) {
43+
var of = AnyObject.f(obj)
44+
if of != nil {
45+
of!()
46+
} else {
47+
print("Object does not respond to the selector \"f\".\n", terminator: "")
48+
}
49+
}
50+
4251
func test_dynamic_lookup_g(_ obj: AnyObject) {
4352
var og = type(of: obj).g
4453
if og != nil {
@@ -64,6 +73,15 @@ test_dynamic_lookup_f(Y())
6473
// CHECK: Z.f()
6574
test_dynamic_lookup_f(Z())
6675

76+
// CHECK-NEXT: (AnyObject) -> Optional<() -> ()>
77+
print(type(of: AnyObject.f))
78+
// CHECK-NEXT: X.f()
79+
test_dynamic_lookup_f_unbound(X())
80+
// CHECK-NEXT: Object does not respond to the selector "f"
81+
test_dynamic_lookup_f_unbound(Y())
82+
// CHECK-NEXT: Z.f()
83+
test_dynamic_lookup_f_unbound(Z())
84+
6785
// CHECK: Class does not respond to the selector "g"
6886
test_dynamic_lookup_g(X())
6987
// CHECK: Y.g()

0 commit comments

Comments
 (0)