mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CodeCompletion] Remove unresolved type from ParsedExpr during operator completion
When doing operator completion, we re-type-check the sequence expression. If we have an unresolve type already applied to `ParsedExpr`, which is the last element of the sequence, the type checker crashes in `validation-test/IDE/crashers_2_fixed/0008-must-conform-to-literal-protocol.swift`, because there are still inactive constraints in the constraint system when it finishes solving. Previously, we would ignore because we allowed free type variables, which we no longer do since the last commit.
This commit is contained in:
@@ -6593,6 +6593,13 @@ void CodeCompletionCallbacksImpl::doneParsing() {
|
||||
if (isDynamicLookup(*ExprType))
|
||||
Lookup.setIsDynamicLookup();
|
||||
Lookup.getValueExprCompletions(*ExprType, ReferencedDecl.getDecl());
|
||||
/// We set the type of ParsedExpr explicitly above. But we don't want an
|
||||
/// unresolved type in our AST when we type check again for operator
|
||||
/// completions. Remove the type of the ParsedExpr and see if we can come up
|
||||
/// with something more useful based on the the full sequence expression.
|
||||
if (ParsedExpr->getType()->is<UnresolvedType>()) {
|
||||
ParsedExpr->setType(nullptr);
|
||||
}
|
||||
Lookup.getOperatorCompletions(ParsedExpr, leadingSequenceExprs);
|
||||
Lookup.getPostfixKeywordCompletions(*ExprType, ParsedExpr);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user