Skip to content

Commit 3479aef

Browse files
committed
[CodeCompletion] Don’t pass LeaveClosureBodiesUnchecked for solver-based code completion
1 parent d611161 commit 3479aef

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

lib/Sema/TypeCheckCodeCompletion.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ getTypeOfExpressionWithoutApplying(Expr *&expr, DeclContext *dc,
302302

303303
ConstraintSystemOptions options;
304304
options |= ConstraintSystemFlags::SuppressDiagnostics;
305-
options |= ConstraintSystemFlags::LeaveClosureBodyUnchecked;
305+
if (!Context.CompletionCallback) {
306+
options |= ConstraintSystemFlags::LeaveClosureBodyUnchecked;
307+
}
306308

307309
// Construct a constraint system from this expression.
308310
ConstraintSystem cs(dc, options);
@@ -395,7 +397,6 @@ getTypeOfCompletionOperatorImpl(DeclContext *DC, Expr *expr,
395397

396398
ConstraintSystemOptions options;
397399
options |= ConstraintSystemFlags::SuppressDiagnostics;
398-
options |= ConstraintSystemFlags::LeaveClosureBodyUnchecked;
399400

400401
// Construct a constraint system from this expression.
401402
ConstraintSystem CS(DC, options);
@@ -606,8 +607,9 @@ bool TypeChecker::typeCheckForCodeCompletion(
606607
options |= ConstraintSystemFlags::AllowFixes;
607608
options |= ConstraintSystemFlags::SuppressDiagnostics;
608609
options |= ConstraintSystemFlags::ForCodeCompletion;
609-
options |= ConstraintSystemFlags::LeaveClosureBodyUnchecked;
610-
610+
if (!Context.CompletionCallback) {
611+
options |= ConstraintSystemFlags::LeaveClosureBodyUnchecked;
612+
}
611613

612614
ConstraintSystem cs(DC, options);
613615

lib/Sema/TypeCheckStmt.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,8 +1995,9 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(
19951995
}
19961996
}
19971997

1998-
TypeChecker::typeCheckASTNode(finder.getRef(), DC,
1999-
/*LeaveBodyUnchecked=*/true);
1998+
bool LeaveBodyUnchecked = !ctx.CompletionCallback;
1999+
2000+
TypeChecker::typeCheckASTNode(finder.getRef(), DC, LeaveBodyUnchecked);
20002001
return false;
20012002
}
20022003

test/IDE/complete_in_closures.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct NestedStructWithClosureMember1 {
104104
struct StructWithClosureMemberAndLocal {
105105
var c = {
106106
var x = 0
107-
#^DELAYED_10?check=WITH_GLOBAL_DECLS_AND_LOCAL1;xfail=sr16012^#
107+
#^DELAYED_10?check=WITH_GLOBAL_DECLS_AND_LOCAL1^#
108108
}
109109
}
110110

test/IDE/complete_skipbody.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ func test(valueOptOpt: MyStruct??) {
4545
case let x where x < 2:
4646
let unrelated3 = FORBIDDEN_Struct()
4747
_ = { xx in
48-
let unrelated4 = FORBIDDEN_Struct()
49-
5048
if xx == localFunc(value.#^FUNCTIONBODY^#) {
5149
let unrelated5 = FORBIDDEN_Struct()
5250
return 1

0 commit comments

Comments
 (0)