diff --git a/include/swift/Sema/ConstraintSystem.h b/include/swift/Sema/ConstraintSystem.h index b98fc5286a338..96fc96eb4b692 100644 --- a/include/swift/Sema/ConstraintSystem.h +++ b/include/swift/Sema/ConstraintSystem.h @@ -2925,7 +2925,7 @@ class ConstraintSystem { /// Whether the argument \p Arg occurs after the code completion token and /// thus should be ignored and not generate any fixes. bool isArgumentIgnoredForCodeCompletion(Expr *Arg) const { - return IgnoredArguments.count(Arg) > 0; + return IgnoredArguments.count(Arg) > 0 && isForCodeCompletion(); } /// Whether the constraint system has ignored any arguments for code diff --git a/test/IDE/complete_call_pattern_heuristics.swift b/test/IDE/complete_call_pattern_heuristics.swift index c2385e43f322e..d1beda0bbdd8f 100644 --- a/test/IDE/complete_call_pattern_heuristics.swift +++ b/test/IDE/complete_call_pattern_heuristics.swift @@ -34,3 +34,7 @@ func testArg2Name3() { // LABELED_FIRSTARG-DAG: Pattern/Local/Flair[ArgLabels]: {#arg1: Int#}[#Int#]; // LABELED_FIRSTARG-NOT: ['(']{#arg1: Int#}, {#arg2: Int#}[')'][#Void#]; +func subscriptAccess(info: [String: Int]) { + info[#^SUBSCRIPT_ACCESS^#] +// SUBSCRIPT_ACCESS: Pattern/Local/Flair[ArgLabels]: {#keyPath: KeyPath<[String : Int], Value>#}[#KeyPath<[String : Int], Value>#]; name=keyPath: +} diff --git a/validation-test/IDE/crashers_2_fixed/0038-setTypeForArgumentIgnoredForCompletion.swift b/validation-test/IDE/crashers_2_fixed/0038-setTypeForArgumentIgnoredForCompletion.swift new file mode 100644 index 0000000000000..81c6b5a973eec --- /dev/null +++ b/validation-test/IDE/crashers_2_fixed/0038-setTypeForArgumentIgnoredForCompletion.swift @@ -0,0 +1,24 @@ +// RUN: %empty-directory(%t) +// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t + +func overloaded(content: () -> Int) {} +func overloaded(@MyResultBuilder stuff: () -> Int) {} + +@resultBuilder struct MyResultBuilder { + static func buildExpression(_ content: Int) -> Int { content } + static func buildBlock() -> Int { 4 } +} + +struct HStack { + init(spacing: Double, @MyResultBuilder content: () -> Int) {} + func qadding(_ length: Double) { } +} + +func test() { + overloaded { + HStack(spacing: #^COMPLETE^#) {} + .qadding(32) + } +} + +// COMPLETE: Literal[Integer]/None/TypeRelation[Convertible]: 0[#Double#]; name=0