Skip to content

Commit 117ab66

Browse files
committed
[IDE] Skip walking serialized non-visible extension decls
fec7a0b skipped all non-visible `ValueDecls` but missed `ExtensionDecls`, which have the same issue. Make sure to skip these too. Resolves rdar://91279771.
1 parent e210db4 commit 117ab66

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

lib/AST/Module.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,10 +2914,18 @@ bool FileUnit::walk(ASTWalker &walker) {
29142914
!walker.shouldWalkSerializedTopLevelInternalDecls();
29152915
for (Decl *D : Decls) {
29162916
if (SkipInternal) {
2917+
// Ignore if the decl isn't visible
29172918
if (auto *VD = dyn_cast<ValueDecl>(D)) {
29182919
if (!VD->isAccessibleFrom(nullptr))
29192920
continue;
29202921
}
2922+
2923+
// Also ignore if the extended nominal isn't visible
2924+
if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
2925+
auto *ND = ED->getExtendedNominal();
2926+
if (ND && !ND->isAccessibleFrom(nullptr))
2927+
continue;
2928+
}
29212929
}
29222930

29232931
#ifndef NDEBUG

test/Index/skip-loaded-internal.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: mkdir -p %t/Frameworks/lib.framework/Modules/lib.swiftmodule
3+
// RUN: mkdir -p %t/Frameworks/lib2.framework/Modules/lib2.swiftmodule
4+
// RUN: split-file %s %t
5+
6+
// RUN: %target-swift-frontend -emit-module -emit-module-source-info -module-name lib2 -o %t/Frameworks/lib2.framework/Modules/lib2.swiftmodule/%module-target-triple.swiftmodule %t/lib2.swift
7+
// RUN: %target-swift-frontend -emit-module -emit-module-source-info -module-name lib -o %t/Frameworks/lib.framework/Modules/lib.swiftmodule/%module-target-triple.swiftmodule %t/lib.swift -Fsystem %t/Frameworks
8+
9+
// RUN: %target-swift-frontend -typecheck -index-system-modules -index-ignore-stdlib -index-store-path %t/idx -Fsystem %t/Frameworks %t/main.swift -disable-deserialization-recovery
10+
11+
//--- main.swift
12+
import lib
13+
14+
//--- lib.swift
15+
@_implementationOnly import lib2
16+
17+
struct InternalS {
18+
func structFunc(p: Lib2S) {}
19+
}
20+
21+
extension InternalS {
22+
func extensionFunc(p: Lib2S) {}
23+
}
24+
25+
//--- lib2.swift
26+
public struct Lib2S {}

0 commit comments

Comments
 (0)