Skip to content

Commit 4a4dded

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 de47a77 commit 4a4dded

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
@@ -2923,10 +2923,18 @@ bool FileUnit::walk(ASTWalker &walker) {
29232923
!walker.shouldWalkSerializedTopLevelInternalDecls();
29242924
for (Decl *D : Decls) {
29252925
if (SkipInternal) {
2926+
// Ignore if the decl isn't visible
29262927
if (auto *VD = dyn_cast<ValueDecl>(D)) {
29272928
if (!VD->isAccessibleFrom(nullptr))
29282929
continue;
29292930
}
2931+
2932+
// Also ignore if the extended nominal isn't visible
2933+
if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
2934+
auto *ND = ED->getExtendedNominal();
2935+
if (ND && !ND->isAccessibleFrom(nullptr))
2936+
continue;
2937+
}
29302938
}
29312939

29322940
#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)