Skip to content

Commit a6c44bf

Browse files
committed
[CSBindings] If hole originates from code completion token avoid fixing it
If the hole is originated from code completion expression let's not try to add a fix, anything connected to a code completion is allowed to be a hole because presence of a code completion token makes constraint system under-constrained due to e.g. lack of expressions on the right-hand side of the token, which are required for a regular type-check.
1 parent c220272 commit a6c44bf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,21 @@ TypeVariableBinding::fixForHole(ConstraintSystem &cs) const {
12421242
auto *dstLocator = TypeVar->getImpl().getLocator();
12431243
auto *srcLocator = Binding.getLocator();
12441244

1245+
// FIXME: This check could be turned into an assert once
1246+
// all code completion kinds are ported to use
1247+
// `TypeChecker::typeCheckForCodeCompletion` API.
1248+
if (cs.isForCodeCompletion()) {
1249+
// If the hole is originated from code completion expression
1250+
// let's not try to fix this, anything connected to a
1251+
// code completion is allowed to be a hole because presence
1252+
// of a code completion token makes constraint system
1253+
// under-constrained due to e.g. lack of expressions on the
1254+
// right-hand side of the token, which are required for a
1255+
// regular type-check.
1256+
if (dstLocator->directlyAt<CodeCompletionExpr>())
1257+
return None;
1258+
}
1259+
12451260
unsigned defaultImpact = 1;
12461261

12471262
if (auto *GP = TypeVar->getImpl().getGenericParameter()) {

0 commit comments

Comments
 (0)