Skip to content

Commit 74a0c2c

Browse files
committed
Take enable-testing into account when computing whether a class has resilient metadata
rdar://87617621
1 parent 840316a commit 74a0c2c

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/AST/Decl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4396,8 +4396,7 @@ bool ClassDecl::hasResilientMetadata() const {
43964396
return false;
43974397

43984398
// If the class is not public, we can't use it outside the module at all.
4399-
if (!getFormalAccessScope(/*useDC=*/nullptr,
4400-
/*treatUsableFromInlineAsPublic=*/true).isPublic())
4399+
if (getEffectiveAccess() < AccessLevel::Public)
44014400
return false;
44024401

44034402
// Otherwise we access metadata members, such as vtable entries, resiliently.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
open class Base {
2+
var x = 1
3+
}
4+
5+
internal class SubClass : Base {
6+
var y = 2
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -enable-testing -emit-ir -enable-library-evolution -module-name=resilient %S/Inputs/resilient-class.swift | %FileCheck %s
3+
4+
@testable import resilient
5+
6+
// CHECK: s9resilient8SubClassCMo
7+
8+
public func testCase() {
9+
let t = SubClass()
10+
print(t.y)
11+
}

0 commit comments

Comments
 (0)