Skip to content

Take enable-testing into account when computing whether a class has resilient metadata #40933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4396,8 +4396,7 @@ bool ClassDecl::hasResilientMetadata() const {
return false;

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

// Otherwise we access metadata members, such as vtable entries, resiliently.
Expand Down
7 changes: 7 additions & 0 deletions test/IRGen/Inputs/resilient-class.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
open class Base {
var x = 1
}

internal class SubClass : Base {
var y = 2
}
11 changes: 11 additions & 0 deletions test/IRGen/testing-enabled-resilient-super-class.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -enable-testing -emit-ir -enable-library-evolution -module-name=resilient %S/Inputs/resilient-class.swift | %FileCheck %s

@testable import resilient

// CHECK: s9resilient8SubClassCMo

public func testCase() {
let t = SubClass()
print(t.y)
}