Skip to content

Commit 1e0621f

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

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
@@ -1006,6 +1006,9 @@ Optional<BraceStmt *> TypeChecker::applyResultBuilderBodyTransform(
10061006
// Solve the constraint system.
10071007
if (cs.getASTContext().CompletionCallback) {
10081008
SmallVector<Solution, 4> solutions;
1009+
cs.Options |= ConstraintSystemFlags::AllowFixes;
1010+
cs.Options |= ConstraintSystemFlags::SuppressDiagnostics;
1011+
cs.Options |= ConstraintSystemFlags::ForCodeCompletion;
10091012
cs.solveForCodeCompletion(solutions);
10101013

10111014
CompletionContextFinder analyzer(func, func->getDeclContext());

test/IDE/complete_call_arg.swift

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

15131513
@MyResultBuilder var body: Int {
1514-
self.ttroke(1, #^AMBIGUOUS_IN_RESULT_BUILDER?xfail=TODO^#)
1514+
self.ttroke(1, #^AMBIGUOUS_IN_RESULT_BUILDER^#)
15151515
// AMBIGUOUS_IN_RESULT_BUILDER: Begin completions, 2 items
15161516
// AMBIGUOUS_IN_RESULT_BUILDER-DAG: Pattern/Local/Flair[ArgLabels]: {#style: String#}[#String#];
15171517
// 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
@@ -388,3 +388,24 @@ func testCompleteIfLetInResultBuilder() {
388388
// IF_LET_IN_RESULT_BUILDER: End completions
389389
}
390390
}
391+
392+
func testOverloadedCallArgs() {
393+
func overloaded(single: Int) -> Int {}
394+
func overloaded(_ first: Int, second: Int) -> Int {}
395+
396+
@resultBuilder struct ViewBuilder {
397+
static func buildBlock(_ content: Int) -> Int { content }
398+
}
399+
400+
struct Test {
401+
@ViewBuilder var body: Int {
402+
overloaded(#^OVERLOADED_CALL_ARG^#, second: 1)
403+
// OVERLOADED_CALL_ARG: Begin completions
404+
// OVERLOADED_CALL_ARG-DAG: Decl[FreeFunction]/Local/Flair[ArgLabels]/TypeRelation[Convertible]: ['(']{#single: Int#}[')'][#Int#];
405+
// OVERLOADED_CALL_ARG-DAG: Decl[FreeFunction]/Local/Flair[ArgLabels]/TypeRelation[Convertible]: ['(']{#(first): Int#}, {#second: Int#}[')'][#Int#];
406+
// OVERLOADED_CALL_ARG-DAG: Literal[Integer]/None/TypeRelation[Convertible]: 0[#Int#];
407+
// OVERLOADED_CALL_ARG: End completions
408+
}
409+
}
410+
411+
}

0 commit comments

Comments
 (0)