Skip to content

[5.7][IDE] Skip walking serialized non-visible extension decls #59029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/AST/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2914,10 +2914,18 @@ bool FileUnit::walk(ASTWalker &walker) {
!walker.shouldWalkSerializedTopLevelInternalDecls();
for (Decl *D : Decls) {
if (SkipInternal) {
// Ignore if the decl isn't visible
if (auto *VD = dyn_cast<ValueDecl>(D)) {
if (!VD->isAccessibleFrom(nullptr))
continue;
}

// Also ignore if the extended nominal isn't visible
if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
auto *ND = ED->getExtendedNominal();
if (ND && !ND->isAccessibleFrom(nullptr))
continue;
}
}

#ifndef NDEBUG
Expand Down
26 changes: 26 additions & 0 deletions test/Index/skip-loaded-internal.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/Frameworks/lib.framework/Modules/lib.swiftmodule
// RUN: mkdir -p %t/Frameworks/lib2.framework/Modules/lib2.swiftmodule
// RUN: split-file %s %t

// 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
// 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

// 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

//--- main.swift
import lib

//--- lib.swift
@_implementationOnly import lib2

struct InternalS {
func structFunc(p: Lib2S) {}
}

extension InternalS {
func extensionFunc(p: Lib2S) {}
}

//--- lib2.swift
public struct Lib2S {}