Skip to content

Commit fec7f6c

Browse files
committed
[CodeCompletion] Fix issue causing the completion status to not be set correctly for pattern completion
We weren’t setting the code completion token status correctly when parsing patterns with code completion tokens. Because of this, in the added test case, the `searchSubject` gets added as a member of `Foo` twice - once in the first pass and once in the second pass, causing an assertion failure. Fixes rdar://80575116 [SR-14687]
1 parent 41a1761 commit fec7f6c

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

lib/Parse/ParsePattern.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ ParserResult<Pattern> Parser::parsePattern() {
11381138
// code complete anything here -- we expect an identifier.
11391139
consumeToken(tok::code_complete);
11401140
}
1141-
return nullptr;
1141+
return makeParserCodeCompletionStatus();
11421142

11431143
case tok::kw_var:
11441144
case tok::kw_let: {

test/IDE/complete_override.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,3 +757,13 @@ class SynthesizedConformance5: SynthesizedConformance2 {
757757
// OVERRIDE_SYNTHESIZED_5-DAG: Decl[Constructor]/Super: required init(from decoder: Decoder) throws {|};
758758
// FIXME: 'required init(from decoder: Decoder)' is suggested twice
759759
}
760+
761+
protocol ProtocolSr14687 {
762+
var value: Int { get }
763+
}
764+
struct StructSr14687: ProtocolSr14687 {
765+
let foo = val, #^MULTI_VAR_DECL_OVERRIDE^#
766+
// MULTI_VAR_DECL_OVERRIDE: Begin completions, 1 items
767+
// MULTI_VAR_DECL_OVERRIDE-DAG: Decl[InstanceVar]/Super: value: Int;
768+
// MULTI_VAR_DECL_OVERRIDE: End completions
769+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %swift-ide-test -code-completion -source-filename %s -code-completion-token=COMPLETE
2+
3+
class Foo {
4+
let searchSubject = Bar<String, #^COMPLETE^#
5+
}

0 commit comments

Comments
 (0)