Skip to content

Commit ece521c

Browse files
authored
Merge pull request #71046 from ahoppen/ahoppen/copyable-completion
[CodeComplete] Emit `Copyable` declaration instead of keyword
2 parents 4c4f3c0 + 7087da9 commit ece521c

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

include/swift/IDE/CompletionLookup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
628628

629629
void getOptionalBindingCompletions(SourceLoc Loc);
630630

631-
void getWithoutConstraintTypes();
631+
void addWithoutConstraintTypes();
632632
};
633633

634634
} // end namespace ide

lib/IDE/CodeCompletion.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,8 @@ void swift::ide::postProcessCompletionResults(
12861286
Kind != CompletionKind::TypeSimpleWithoutDot &&
12871287
Kind != CompletionKind::TypeSimpleWithDot &&
12881288
Kind != CompletionKind::TypeDeclResultBeginning &&
1289-
Kind != CompletionKind::GenericRequirement) {
1289+
Kind != CompletionKind::GenericRequirement &&
1290+
Kind != CompletionKind::WithoutConstraintType) {
12901291
flair |= CodeCompletionFlairBit::RareTypeAtCurrentPosition;
12911292
modified = true;
12921293
}
@@ -1974,7 +1975,7 @@ void CodeCompletionCallbacksImpl::doneParsing(SourceFile *SrcFile) {
19741975
}
19751976

19761977
case CompletionKind::WithoutConstraintType: {
1977-
Lookup.getWithoutConstraintTypes();
1978+
Lookup.addWithoutConstraintTypes();
19781979
break;
19791980
}
19801981

lib/IDE/CompletionLookup.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3444,8 +3444,8 @@ void CompletionLookup::getOptionalBindingCompletions(SourceLoc Loc) {
34443444
/*IncludeTopLevel=*/false, Loc);
34453445
}
34463446

3447-
void CompletionLookup::getWithoutConstraintTypes() {
3448-
// FIXME: Once we have a typealias declaration for copyable, we should be
3449-
// returning that instead of a keyword (rdar://109107817).
3450-
addKeyword("Copyable");
3447+
void CompletionLookup::addWithoutConstraintTypes() {
3448+
auto *CopyableDecl = Ctx.getProtocol(KnownProtocolKind::Copyable);
3449+
addNominalTypeRef(CopyableDecl, DeclVisibilityKind::VisibleAtTopLevel,
3450+
DynamicLookupInfo());
34513451
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %batch-code-completion
22

33
struct FileDescriptor: ~#^COMPLETE^# {}
4-
// FIXME: This should be emitting a `Copyable` declaration instead of a keyword, once there is a declaration for `Copyable`
5-
// COMPLETE: Keyword/None: Copyable; name=Copyable
4+
// COMPLETE: Decl[Protocol]/OtherModule[Swift]/IsSystem: Copyable[#Copyable#]; name=Copyable

0 commit comments

Comments
 (0)