File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1165,7 +1165,13 @@ static bool isPolymorphic(const AbstractStorageDecl *storage) {
1165
1165
1166
1166
case DeclKind::Class:
1167
1167
// Final properties can always be direct, even in classes.
1168
- return !storage->isFinal ();
1168
+ if (storage->isFinal ())
1169
+ return false ;
1170
+ // Extension properties are statically dispatched, unless they're @objc.
1171
+ if (storage->getDeclContext ()->isExtensionContext ()
1172
+ && !storage->isObjC ())
1173
+ return false ;
1174
+ return true ;
1169
1175
}
1170
1176
llvm_unreachable (" bad DeclKind" );
1171
1177
}
Original file line number Diff line number Diff line change 1
1
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-keypath-components -emit-silgen -import-objc-header %S/Inputs/keypaths_objc.h %s | %FileCheck %s
2
+ // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-keypath-components -emit-ir -import-objc-header %S/Inputs/keypaths_objc.h %s
2
3
// REQUIRES: objc_interop
3
4
4
5
import Foundation
@@ -55,3 +56,23 @@ func objcKeypathIdentifiers() {
55
56
// CHECK: keypath $KeyPath<Foo, Int>, (objc "int"; {{.*}} id #Foo.int!getter.1 :
56
57
_ = \Foo . int
57
58
}
59
+
60
+ struct X { }
61
+
62
+ extension NSObject {
63
+ var x : X { return X ( ) }
64
+ @objc var objc : Int { return 0 }
65
+ @objc dynamic var dynamic : Int { return 0 }
66
+ }
67
+
68
+ // CHECK-LABEL: sil hidden @{{.*}}nonobjcExtensionOfObjCClass
69
+ func nonobjcExtensionOfObjCClass( ) {
70
+ // Should be treated as a statically-dispatch property
71
+ // CHECK: keypath $KeyPath<NSObject, X>, ({{.*}} id @
72
+ _ = \NSObject . x
73
+ // CHECK: keypath $KeyPath<NSObject, Int>, ({{.*}} id #NSObject.objc!getter.1.foreign
74
+ _ = \NSObject . objc
75
+ // CHECK: keypath $KeyPath<NSObject, Int>, ({{.*}} id #NSObject.dynamic!getter.1.foreign
76
+ _ = \NSObject . dynamic
77
+
78
+ }
You can’t perform that action at this time.
0 commit comments