Skip to content

Discard non-indexed relations instead of entire references. #79577

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 1 commit into from
Feb 25, 2025
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
4 changes: 3 additions & 1 deletion lib/Index/Index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,9 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
assert(D);
if (auto *VD = dyn_cast<ValueDecl>(D)) {
if (!shouldIndex(VD, /*IsRef*/ true))
return true;
// Let the caller continue while discarding the relation to a symbol
// that won't appear in the index.
return false;
}
auto Match = std::find_if(Info.Relations.begin(), Info.Relations.end(),
[D](IndexRelation R) { return R.decl == D; });
Expand Down
66 changes: 66 additions & 0 deletions test/Index/index_private_type_receiver.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/SDK)
// RUN: split-file %s %t
//
// RUN: mkdir -p %t/SDK/Frameworks/FakeSystem.framework/Modules/FakeSystem.swiftmodule
// RUN: %target-swift-frontend \
// RUN: -emit-module \
// RUN: -module-name FakeSystem \
// RUN: -o %t/SDK/Frameworks/FakeSystem.framework/Modules/FakeSystem.swiftmodule/%module-target-triple.swiftmodule \
// RUN: -swift-version 5 \
// RUN: %t/FakeSystem.swift
//
// RUN: %empty-directory(%t/idx)
// RUN: %empty-directory(%t/modulecache)
//
// --- Built with indexing
// RUN: %target-swift-frontend \
// RUN: -typecheck \
// RUN: -index-system-modules \
// RUN: -index-ignore-stdlib \
// RUN: -index-store-path %t/idx \
// RUN: -sdk %t/SDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: %t/view.swift
//
// --- Check the index.
// RUN: c-index-test core -print-record %t/idx | %FileCheck %s
//

//--- FakeSystem.swift
public protocol View {
}

public protocol ViewModifier {
associatedtype Body: View
typealias Content = _HiddenView<Self>
func body(content: Self.Content) -> Self.Body
}

public struct _HiddenView<M>: View where M: ViewModifier {
init(m: M) {}
}

public struct _HiddenModifier: ViewModifier {
public func body(content: Content) -> some View {
return _HiddenView(m: self)
}
}

extension View {
public func background() -> some View {
return _HiddenView(m: _HiddenModifier())
}
}

//--- view.swift
import FakeSystem

private struct Mod: FakeSystem.ViewModifier {
func body(content: Content) -> some View {
content
.background()
// CHECK: 6:8 | instance-method/Swift | s:10FakeSystem4ViewPAAE10backgroundQryF | Ref,Call,Dyn{{.*}}
}
}