Skip to content

Commit c69be5c

Browse files
authored
Merge pull request #65841 from ahoppen/ahoppen/5.9/stress-tester-fixes
[5.9][CodeCompletion] Fix an assertion failure found by the stress tester
2 parents cd83ac2 + d4b0b0b commit c69be5c

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2925,7 +2925,7 @@ class ConstraintSystem {
29252925
/// Whether the argument \p Arg occurs after the code completion token and
29262926
/// thus should be ignored and not generate any fixes.
29272927
bool isArgumentIgnoredForCodeCompletion(Expr *Arg) const {
2928-
return IgnoredArguments.count(Arg) > 0;
2928+
return IgnoredArguments.count(Arg) > 0 && isForCodeCompletion();
29292929
}
29302930

29312931
/// Whether the constraint system has ignored any arguments for code

test/IDE/complete_call_pattern_heuristics.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ func testArg2Name3() {
3434
// LABELED_FIRSTARG-DAG: Pattern/Local/Flair[ArgLabels]: {#arg1: Int#}[#Int#];
3535
// LABELED_FIRSTARG-NOT: ['(']{#arg1: Int#}, {#arg2: Int#}[')'][#Void#];
3636

37+
func subscriptAccess(info: [String: Int]) {
38+
info[#^SUBSCRIPT_ACCESS^#]
39+
// SUBSCRIPT_ACCESS: Pattern/Local/Flair[ArgLabels]: {#keyPath: KeyPath<[String : Int], Value>#}[#KeyPath<[String : Int], Value>#]; name=keyPath:
40+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
3+
4+
func overloaded(content: () -> Int) {}
5+
func overloaded(@MyResultBuilder stuff: () -> Int) {}
6+
7+
@resultBuilder struct MyResultBuilder {
8+
static func buildExpression(_ content: Int) -> Int { content }
9+
static func buildBlock() -> Int { 4 }
10+
}
11+
12+
struct HStack {
13+
init(spacing: Double, @MyResultBuilder content: () -> Int) {}
14+
func qadding(_ length: Double) { }
15+
}
16+
17+
func test() {
18+
overloaded {
19+
HStack(spacing: #^COMPLETE^#) {}
20+
.qadding(32)
21+
}
22+
}
23+
24+
// COMPLETE: Literal[Integer]/None/TypeRelation[Convertible]: 0[#Double#]; name=0

0 commit comments

Comments
 (0)