mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CS] Diagnose UnresolvedPatternExprs as part of constraint solving
Instead of diagnosing in CSApply, let's create a fix and diagnose in the solver instead. Additionally, make sure we assign ErrorTypes to any VarDecls bound by the invalid pattern, which fixes a crash. rdar://110638279
This commit is contained in:
@@ -4604,24 +4604,11 @@ namespace {
|
||||
Expr *visitDiscardAssignmentExpr(DiscardAssignmentExpr *expr) {
|
||||
return simplifyExprType(expr);
|
||||
}
|
||||
|
||||
|
||||
Expr *visitUnresolvedPatternExpr(UnresolvedPatternExpr *expr) {
|
||||
// If we end up here, we should have diagnosed somewhere else
|
||||
// already.
|
||||
Expr *simplified = simplifyExprType(expr);
|
||||
// Invalidate 'VarDecl's inside the pattern.
|
||||
expr->getSubPattern()->forEachVariable([](VarDecl *VD) {
|
||||
VD->setInvalid();
|
||||
});
|
||||
if (!SuppressDiagnostics
|
||||
&& !cs.getType(simplified)->is<UnresolvedType>()) {
|
||||
auto &de = cs.getASTContext().Diags;
|
||||
de.diagnose(simplified->getLoc(), diag::pattern_in_expr,
|
||||
expr->getSubPattern()->getDescriptiveKind());
|
||||
}
|
||||
return simplified;
|
||||
llvm_unreachable("Should have diagnosed");
|
||||
}
|
||||
|
||||
|
||||
Expr *visitBindOptionalExpr(BindOptionalExpr *expr) {
|
||||
return simplifyExprType(expr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user