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) {
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+
4251func 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()
6574test_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"
6886test_dynamic_lookup_g ( X ( ) )
6987// CHECK: Y.g()
You can’t perform that action at this time.
0 commit comments