Skip to content

Commit 186493e

Browse files
authored
Merge pull request swiftlang#35575 from egorzhdan/sk-impl-only
SourceKit: do not print implementation-only imports
2 parents 5d75b3e + cb59366 commit 186493e

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lib/IDE/ModuleInterfacePrinting.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,9 @@ void swift::ide::printModuleInterface(
609609
}
610610

611611
auto ShouldPrintImport = [&](ImportDecl *ImportD) -> bool {
612+
if (ImportD->getAttrs().hasAttribute<ImplementationOnlyAttr>())
613+
return false;
614+
612615
if (!TargetClangMod)
613616
return true;
614617
if (ImportD->getModule() == TargetMod)

lib/Serialization/ModuleFile.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ void ModuleFile::getImportDecls(SmallVectorImpl<Decl *> &Results) {
499499
if (Dep.isExported())
500500
ID->getAttrs().add(
501501
new (Ctx) ExportedAttr(/*IsImplicit=*/false));
502+
if (Dep.isImplementationOnly())
503+
ID->getAttrs().add(
504+
new (Ctx) ImplementationOnlyAttr(/*IsImplicit=*/false));
505+
502506
ImportDecls.push_back(ID);
503507
}
504508
Bits.ComputedImportDecls = true;

test/Serialization/Recovery/implementation-only-override.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: %FileCheck %s < %t/Library.txt
55

66
// CHECK: import FooKit
7-
// CHECK: import FooKit_SECRET
7+
// CHECK-NOT: import FooKit_SECRET
88

99
import FooKit
1010
@_implementationOnly import FooKit_SECRET

0 commit comments

Comments
 (0)