File tree Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -1038,6 +1038,11 @@ emitKeyPathComponent(IRGenModule &IGM,
1038
1038
// native class resilience. We never directly access ObjC-imported
1039
1039
// ivars so we can disregard ObjC ivar resilience for this computation
1040
1040
// and start counting at the Swift native root.
1041
+ if (loweredClassTy.getASTType ()->hasTypeParameter ())
1042
+ loweredClassTy = SILType::getPrimitiveObjectType (
1043
+ GenericEnvironment::mapTypeIntoContext (
1044
+ genericEnv, loweredClassTy.getASTType ())
1045
+ ->getCanonicalType ());
1041
1046
switch (getClassFieldAccess (IGM, loweredClassTy, property)) {
1042
1047
case FieldAccess::ConstantDirect:
1043
1048
case FieldAccess::ConstantIndirect:
Original file line number Diff line number Diff line change
1
+ @propertyWrapper
2
+ public struct Wrapper < Value> {
3
+ var value : Value
4
+
5
+ public init ( wrappedValue: Value ) {
6
+ self . init ( initialValue: wrappedValue)
7
+ }
8
+
9
+ public init ( initialValue: Value ) {
10
+ value = initialValue
11
+ }
12
+
13
+ public var wrappedValue : Value {
14
+ get { fatalError ( " unreachable " ) }
15
+ set { fatalError ( " unreachable " ) }
16
+ }
17
+
18
+ public static subscript< T: AnyObject > (
19
+ _enclosingInstance object: T ,
20
+ wrapped wrappedKeyPath: ReferenceWritableKeyPath < T , Value > ,
21
+ storage storageKeyPath: ReferenceWritableKeyPath < T , Self >
22
+ ) -> Value {
23
+ get {
24
+ object [ keyPath: storageKeyPath] . value
25
+ }
26
+ set {
27
+ object [ keyPath: storageKeyPath] . value = newValue
28
+ }
29
+ }
30
+ }
31
+
32
+ open class ResilientBase {
33
+ public init ( ) { }
34
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-swift-frontend -enable-library-evolution -emit-module-path=%t/ResilientBase.swiftmodule -module-name=ResilientBase %S/Inputs/ResilientBase.swift
3
+ // RUN: %target-swift-frontend -primary-file %s -emit-ir -I %t -profile-generate -profile-coverage-mapping
4
+
5
+ // This test use to crash because we emitted a FieldAccess::NonConstantDirect for _t.
6
+
7
+ import ResilientBase
8
+
9
+ class TheTest {
10
+ func test_resilientSubclassCrasher( ) {
11
+ final class SubclassOfResilientBase < T> : ResilientBase {
12
+ @Wrapper var t : T
13
+
14
+ init ( _ t: T ) {
15
+ self . t = t
16
+ }
17
+ }
18
+ _ = SubclassOfResilientBase ( 0 )
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments