File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1481,6 +1481,10 @@ bool TypeBase::satisfiesClassConstraint() {
1481
1481
}
1482
1482
1483
1483
bool TypeBase::isCallableNominalType (DeclContext *dc) {
1484
+ // Don't allow callAsFunction to be used with dynamic lookup.
1485
+ if (isAnyObject ())
1486
+ return false ;
1487
+
1484
1488
// If the type cannot have members, we're done.
1485
1489
if (!mayHaveMembers ())
1486
1490
return false ;
Original file line number Diff line number Diff line change @@ -398,3 +398,13 @@ class HasMethodWithDefault {
398
398
func testAnyObjectWithDefault( _ x: AnyObject ) {
399
399
x. hasDefaultParam ( )
400
400
}
401
+
402
+ // SR-11829: Don't perform dynamic lookup for callAsFunction.
403
+ class ClassWithObjcCallAsFunction {
404
+ @objc func callAsFunction( ) { }
405
+ }
406
+
407
+ func testCallAsFunctionAnyObject( _ x: AnyObject ) {
408
+ x ( ) // expected-error {{cannot call value of non-function type 'AnyObject'}}
409
+ x. callAsFunction ( ) // Okay.
410
+ }
You can’t perform that action at this time.
0 commit comments