@@ -8365,12 +8365,13 @@ bool InvalidEmptyKeyPathFailure::diagnoseAsError() {
8365
8365
}
8366
8366
8367
8367
bool InvalidPatternInExprFailure::diagnoseAsError () {
8368
- // Check to see if we have something like 'case <fn>(let foo)', where <fn>
8369
- // has a fix associated with it. In such a case, it's more likely than not
8370
- // that the user is trying to write an EnumElementPattern, but has made some
8371
- // kind of mistake in the function expr that causes it to be treated as an
8372
- // ExprPattern. Emitting an additional error for the out of place 'let foo' is
8373
- // just noise in that case, so let's avoid diagnosing.
8368
+ // Check to see if we have something like 'case <fn>(let foo)', where either
8369
+ // <fn> or the call itself has a fix associated with it. In such a case, it's
8370
+ // more likely than not that the user is trying to write an
8371
+ // EnumElementPattern, but has made some kind of mistake in the function expr
8372
+ // that causes it to be treated as an ExprPattern. Emitting an additional
8373
+ // error for the out of place 'let foo' is just noise in that case, so let's
8374
+ // avoid diagnosing.
8374
8375
llvm::SmallPtrSet<Expr *, 4 > fixAnchors;
8375
8376
for (auto *fix : getSolution ().Fixes ) {
8376
8377
if (auto *anchor = getAsExpr (fix->getAnchor ()))
@@ -8380,7 +8381,7 @@ bool InvalidPatternInExprFailure::diagnoseAsError() {
8380
8381
auto *E = castToExpr (getLocator ()->getAnchor ());
8381
8382
while (auto *parent = findParentExpr (E)) {
8382
8383
if (auto *CE = dyn_cast<CallExpr>(parent)) {
8383
- if (fixAnchors.contains (CE->getFn ()))
8384
+ if (fixAnchors.contains (CE) || fixAnchors. contains (CE ->getFn ()))
8384
8385
return false ;
8385
8386
}
8386
8387
E = parent;
0 commit comments