Skip to content

Commit b29f010

Browse files
authored
[ModuleInterface] Don't print extensions of internal types (#19440)
1 parent 639fb1d commit b29f010

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ PrintOptions PrintOptions::printTextualInterfaceFile() {
109109
}
110110
}
111111

112+
// Skip extensions that extend things we wouldn't print.
113+
if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
114+
if (!shouldPrint(ED->getExtendedNominal(), options))
115+
return false;
116+
// FIXME: We also need to check the generic signature for constraints
117+
// that we can't reference.
118+
}
119+
112120
// Skip typealiases that just redeclare generic parameters.
113121
if (auto *alias = dyn_cast<TypeAliasDecl>(D)) {
114122
if (alias->isImplicit()) {

test/ModuleInterface/access-filter.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,12 @@ extension PublicStruct {
102102
// CHECK: public private(set) static var secretlySettable: Int{{$}}
103103
public private(set) static var secretlySettable: Int = 0
104104
} // CHECK: {{^[}]$}}
105+
106+
extension InternalStruct_BAD: PublicProto {
107+
internal static var dummy: Int { return 0 }
108+
}
109+
110+
// CHECK: extension UFIStruct : PublicProto {{[{]$}}
111+
extension UFIStruct: PublicProto {
112+
internal static var dummy: Int { return 0 }
113+
} // CHECK-NEXT: {{^[}]$}}

0 commit comments

Comments
 (0)