Skip to content

[CodeCompletion] Remove a hack adding type matching nominal types #41787

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
Mar 14, 2022
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
16 changes: 0 additions & 16 deletions lib/IDE/CompletionLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2634,22 +2634,6 @@ void CompletionLookup::getValueCompletionsInDeclContext(SourceLoc Loc,
RequestedResultsTy::toplevelResults().withModuleQualifier(
ModuleQualifier));

// Manually add any expected nominal types from imported modules so that
// they get their expected type relation. Don't include protocols, since
// they can't be initialized from the type name.
// FIXME: this does not include types that conform to an expected protocol.
// FIXME: this creates duplicate results.
for (auto T : expectedTypeContext.getPossibleTypes()) {
if (auto NT = T->getAs<NominalType>()) {
if (auto NTD = NT->getDecl()) {
if (!isa<ProtocolDecl>(NTD) && NTD->getModuleContext() != CurrModule) {
addNominalTypeRef(NT->getDecl(),
DeclVisibilityKind::VisibleAtTopLevel, {});
}
}
}
}

if (CompletionContext) {
// FIXME: this is an awful simplification that says all and only enums can
// use implicit member syntax (leading dot). Computing the accurate answer
Expand Down
8 changes: 8 additions & 0 deletions test/IDE/complete_value_expr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2041,3 +2041,11 @@ func testProtocolMetatype(protoProto: MetaProto.Protocol, protoType: MetaProto.T
// PROTOCOLMETA_3: End completions
}

func testRdar90136020() {
let a: Int64 = #^RDAR90136020^#
// RDAR90136020: Begin completions
// RDAR90136020-NOT: name=Int64{{$}}
// RDAR90136020: Decl[Struct]/OtherModule[Swift]/IsSystem/TypeRelation[Identical]: Int64[#Int64#]; name=Int64
// RDAR90136020-NOT: name=Int64{{$}}
// RDAR90136020: End completions
}