Skip to content

Commit 527a79e

Browse files
committed
[IDE] Set constraint system options from solveForCodeCompletion in applyResultBuilderBodyTransform when solving for code completion
1 parent c00428a commit 527a79e

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

lib/Sema/BuilderTransform.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,9 @@ llvm::Optional<BraceStmt *> TypeChecker::applyResultBuilderBodyTransform(
10081008
// Solve the constraint system.
10091009
if (cs.getASTContext().CompletionCallback) {
10101010
SmallVector<Solution, 4> solutions;
1011+
cs.Options |= ConstraintSystemFlags::AllowFixes;
1012+
cs.Options |= ConstraintSystemFlags::SuppressDiagnostics;
1013+
cs.Options |= ConstraintSystemFlags::ForCodeCompletion;
10111014
cs.solveForCodeCompletion(solutions);
10121015

10131016
SyntacticElementTarget funcTarget(func);

test/IDE/complete_call_arg.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ struct AmbiguousCallInResultBuilder {
13831383
func ttroke(_ content: Int, lineWidth: Int = 1) -> Int { 42 }
13841384

13851385
@MyResultBuilder var body: Int {
1386-
self.ttroke(1, #^AMBIGUOUS_IN_RESULT_BUILDER?xfail=TODO^#)
1386+
self.ttroke(1, #^AMBIGUOUS_IN_RESULT_BUILDER^#)
13871387
// AMBIGUOUS_IN_RESULT_BUILDER: Begin completions, 2 items
13881388
// AMBIGUOUS_IN_RESULT_BUILDER-DAG: Pattern/Local/Flair[ArgLabels]: {#style: String#}[#String#];
13891389
// AMBIGUOUS_IN_RESULT_BUILDER-DAG: Pattern/Local/Flair[ArgLabels]: {#lineWidth: Int#}[#Int#];

test/IDE/complete_in_result_builder.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,3 +360,24 @@ func testCompleteIfLetInResultBuilder() {
360360
// IF_LET_IN_RESULT_BUILDER: End completions
361361
}
362362
}
363+
364+
func testOverloadedCallArgs() {
365+
func overloaded(single: Int) -> Int {}
366+
func overloaded(_ first: Int, second: Int) -> Int {}
367+
368+
@resultBuilder struct ViewBuilder {
369+
static func buildBlock(_ content: Int) -> Int { content }
370+
}
371+
372+
struct Test {
373+
@ViewBuilder var body: Int {
374+
overloaded(#^OVERLOADED_CALL_ARG^#, second: 1)
375+
// OVERLOADED_CALL_ARG: Begin completions
376+
// OVERLOADED_CALL_ARG-DAG: Decl[FreeFunction]/Local/Flair[ArgLabels]/TypeRelation[Convertible]: ['(']{#single: Int#}[')'][#Int#];
377+
// OVERLOADED_CALL_ARG-DAG: Decl[FreeFunction]/Local/Flair[ArgLabels]/TypeRelation[Convertible]: ['(']{#(first): Int#}, {#second: Int#}[')'][#Int#];
378+
// OVERLOADED_CALL_ARG-DAG: Literal[Integer]/None/TypeRelation[Convertible]: 0[#Int#];
379+
// OVERLOADED_CALL_ARG: End completions
380+
}
381+
}
382+
383+
}

0 commit comments

Comments
 (0)