Skip to content

Commit ea1b2d0

Browse files
James BrownJames Brown
authored andcommitted
fixup! issue #65913 - Correct wrong insertion point suggestion when using shorthand optional binding by looking for implicitDeclRefExpr that is optional and points to a VarDecl. If we have that, get the name and insert with fixItInsertAfter instead of fixItInsert.
1 parent 035a980 commit ea1b2d0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lib/Sema/TypeCheckEffects.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3599,11 +3599,9 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
35993599
if (!anchor->getType()->isOptional())
36003600
return nullptr;
36013601
anchor->forEachChildExpr([&](Expr *expr) -> Expr * {
3602-
if (auto declRef = dyn_cast<DeclRefExpr>(expr)) {
3603-
if (declRef && declRef->isImplicit()) {
3604-
varDecl = dyn_cast<VarDecl>(declRef->getDecl());
3605-
return nullptr;
3606-
}
3602+
if (isa<DeclRefExpr>(expr) && expr->isImplicit()) {
3603+
varDecl = dyn_cast<VarDecl>(expr->getReferencedDecl().getDecl());
3604+
return nullptr;
36073605
}
36083606
return expr;
36093607
});
@@ -3615,7 +3613,7 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
36153613
return diag.downgradeToWarning;
36163614
});
36173615

3618-
if (auto varDecl = findShorthandOptionalBinding(anchor)) {
3616+
if (auto *varDecl = findShorthandOptionalBinding(anchor)) {
36193617
Ctx.Diags.diagnose(anchor->getStartLoc(), diag::async_expr_without_await)
36203618
.warnUntilSwiftVersionIf(downgradeToWarning, 6)
36213619
.fixItInsertAfter(anchor->getStartLoc(),

0 commit comments

Comments
 (0)