Skip to content

Commit 2c33b72

Browse files
committed
IRGen: Mangle symbolic type references as private types even with enable-private-imports
1 parent de65d30 commit 2c33b72

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/IRGen/IRGenMangler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ IRGenMangler::withSymbolicReferences(IRGenModule &IGM,
103103
// when the referent may be in another file, once the on-disk
104104
// ObjectMemoryReader can handle them.
105105
// Private entities are known to be accessible.
106-
if (type->getEffectiveAccess() >= AccessLevel::Internal &&
106+
auto formalAccessScope = type->getFormalAccessScope(nullptr, true);
107+
if ((formalAccessScope.isPublic() || formalAccessScope.isInternal()) &&
107108
(!IGM.CurSourceFile ||
108109
IGM.CurSourceFile != type->getParentSourceFile()))
109110
return false;

test/IRGen/symbolic_references.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s
2+
// RUN: %target-swift-frontend -emit-ir -enable-private-imports %s | %FileCheck %s --check-prefix=PRIVATE
3+
4+
protocol P {
5+
associatedtype A
6+
}
7+
// CHECK: @"symbolic _____ 19symbolic_references3Foo016_{{.*}}V5InnerV9InnermostV" = linkonce_odr hidden constant <{ i8, i32, i8 }> <{ i8 1,
8+
// CHECK: @"symbolic _____ 19symbolic_references3Foo016_{{.*}}V5InnerV" = linkonce_odr hidden constant <{ i8, i32, i8 }> <{ i8 1
9+
// CHECK: @"symbolic _____ 19symbolic_references3Foo016_{{.*}}V" = linkonce_odr hidden constant <{ i8, i32, i8 }> <{ i8 1
10+
11+
// PRIVATE: @"symbolic _____ 19symbolic_references3Foo016_{{.*}}V5InnerV9InnermostV" = linkonce_odr hidden constant <{ i8, i32, i8 }> <{ i8 2
12+
// PRIVATE: @"symbolic _____ 19symbolic_references3Foo016_{{.*}}V5InnerV" = linkonce_odr hidden constant <{ i8, i32, i8 }> <{ i8 1
13+
// PRIVATE: @"symbolic _____ 19symbolic_references3Foo016_{{.*}}V" = linkonce_odr hidden constant <{ i8, i32, i8 }> <{ i8 1
14+
fileprivate struct Foo {
15+
fileprivate struct Inner: P {
16+
fileprivate struct Innermost { }
17+
typealias A = Innermost
18+
}
19+
}

0 commit comments

Comments
 (0)