File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,17 @@ template <class Impl> class ClassMetadataVisitor
116
116
if (superclassDecl->hasClangNode ()) {
117
117
// Nothing to do; Objective-C classes do not add new members to
118
118
// Swift class metadata.
119
- } else if (IGM.hasResilientMetadata (superclassDecl, ResilienceExpansion::Maximal)) {
119
+
120
+ // Super class metadata is resilient if
121
+ // the superclass is resilient when viewed from the currrent module.
122
+ // But not if the current class is defined in an external module and
123
+ // not publically accessible (e.g private or internal). This would
124
+ // normally not happen except if we compile theClass's module with
125
+ // enable-testing.
126
+ } else if (IGM.hasResilientMetadata (superclassDecl, ResilienceExpansion::Maximal) &&
127
+ (theClass->getModuleContext () == IGM.getSwiftModule () ||
128
+ theClass->getFormalAccessScope (/* useDC=*/ nullptr ,
129
+ /* treatUsableFromInlineAsPublic=*/ true ).isPublic ())) {
120
130
// Runtime metadata instantiation will initialize our field offset
121
131
// vector and vtable entries.
122
132
//
Original file line number Diff line number Diff line change
1
+ open class Base {
2
+ var x = 1
3
+ }
4
+
5
+ internal class SubClass : Base {
6
+ var y = 2
7
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-swift-frontend -enable-testing -enable-library-evolution -module-name=resilient %S/Inputs/resilient-class.swift -emit-module -emit-module-path %t/resilient.swiftmodule
3
+ // RUN: %target-swift-frontend -I %t -emit-ir %s | %FileCheck %s
4
+
5
+ // Check that linking succeeds.
6
+ // RUN: %empty-directory(%t)
7
+ // RUN: %target-build-swift-dylib(%t/%target-library-name(resilient)) %S/Inputs/resilient-class.swift -module-name resilient -emit-module -emit-module-path %t/resilient.swiftmodule -enable-library-evolution -enable-testing
8
+ // RUN: %target-build-swift -I %t -L %t -lresilient %s -o %t/main %target-rpath(%t)
9
+ // RUN: %target-build-swift -O -I %t -L %t -lresilient %s -o %t/main %target-rpath(%t)
10
+
11
+ @testable import resilient
12
+
13
+ // Don't access via the class offset global. Use a fragile access pattern instead.
14
+
15
+ // CHECK-NOT: s9resilient8SubClassCMo
16
+
17
+ public func testCase( ) {
18
+ let t = SubClass ( )
19
+ print ( t. y)
20
+ }
You can’t perform that action at this time.
0 commit comments