Skip to content

Commit ef7f8f7

Browse files
authored
Merge pull request #6102 from benlangmuir/fix-032
[code-completion] Allow ErrorType in solution to avoid assertion failure
2 parents 900d6dc + c01bff7 commit ef7f8f7

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,10 +1630,14 @@ getTypeOfExpressionWithoutApplying(Expr *&expr, DeclContext *dc,
16301630
auto &solution = viable[0];
16311631
Type exprType = solution.simplifyType(*this, expr->getType());
16321632

1633-
assert(exprType && !exprType->hasError() && "erroneous solution?");
1634-
assert(!exprType->hasTypeVariable() &&
1633+
assert(exprType && !exprType->hasTypeVariable() &&
16351634
"free type variable with FreeTypeVariableBinding::GenericParameters?");
16361635

1636+
if (exprType->hasError()) {
1637+
recoverOriginalType();
1638+
return None;
1639+
}
1640+
16371641
// Dig the declaration out of the solution.
16381642
auto semanticExpr = expr->getSemanticsProvidingExpr();
16391643
auto topLocator = cs.getConstraintLocator(semanticExpr);

validation-test/IDE/crashers/108-swift-typechecker-typecheckcompletionsequence.swift

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
func c{case
3+
let a#^A^#}

0 commit comments

Comments
 (0)