Skip to content

[CodeCompletion] Resolve witnesses when conformance in different file to avoid dups #17288

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
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: 6 additions & 2 deletions lib/AST/LookupVisibleDecls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,13 @@ static void lookupDeclsFromProtocolsBeingConformedTo(
continue;
}
if (auto *VD = dyn_cast<ValueDecl>(Member)) {
if (TypeResolver)
if (TypeResolver) {
TypeResolver->resolveDeclSignature(VD);

if (!NormalConformance->hasWitness(VD) &&
(Conformance->getDeclContext()->getParentSourceFile() !=
FromContext->getParentSourceFile()))
TypeResolver->resolveWitness(NormalConformance, VD);
}
// Skip value requirements that have corresponding witnesses. This cuts
// down on duplicates.
if (!NormalConformance->hasWitness(VD) ||
Expand Down
6 changes: 0 additions & 6 deletions test/IDE/complete_multiple_files.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ func testObjectExpr() {
// T1-NEXT: Keyword[self]/CurrNominal: self[#FooStruct#]; name=self
// T1-NEXT: Decl[InstanceVar]/CurrNominal: instanceVar[#Int#]{{; name=.+$}}
// T1-NEXT: Decl[InstanceMethod]/CurrNominal: instanceFunc0()[#Void#]{{; name=.+$}}
//
// FIX-ME(SR-7225): We shouldn't duplicate this.
// T1-NEXT: Decl[InstanceVar]/Super: instanceVar[#Int#]{{; name=.+$}}
// T1-NEXT: End completions

func testGenericObjectExpr() {
Expand All @@ -28,9 +25,6 @@ func testGenericObjectExpr() {
// T2-NEXT: Keyword[self]/CurrNominal: self[#GenericFooStruct<Void>#]; name=self
// T2-NEXT: Decl[InstanceVar]/CurrNominal: instanceVar[#Int#]{{; name=.+$}}
// T2-NEXT: Decl[InstanceMethod]/CurrNominal: instanceFunc0()[#Void#]{{; name=.+$}}
//
// FIX-ME(SR-7225): We shouldn't duplicate this.
// T2-NEXT: Decl[InstanceVar]/Super: instanceVar[#Int#]{{; name=.+$}}
// T2-NEXT: End completions

func topLevel1() {
Expand Down