File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,15 @@ func test_dynamic_lookup_f(_ obj: AnyObject) {
39
39
}
40
40
}
41
41
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
+
42
51
func test_dynamic_lookup_g( _ obj: AnyObject ) {
43
52
var og = type ( of: obj) . g
44
53
if og != nil {
@@ -64,6 +73,15 @@ test_dynamic_lookup_f(Y())
64
73
// CHECK: Z.f()
65
74
test_dynamic_lookup_f ( Z ( ) )
66
75
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
+
67
85
// CHECK: Class does not respond to the selector "g"
68
86
test_dynamic_lookup_g ( X ( ) )
69
87
// CHECK: Y.g()
You can’t perform that action at this time.
0 commit comments