Skip to content

Commit d9be4a7

Browse files
committed
Update check for Optional.none
1 parent 992a9d3 commit d9be4a7

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,13 +1299,10 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
12991299
bool isTypeCheckedOptionalNil(Expr *E) {
13001300
if (dyn_cast<NilLiteralExpr>(E)) return true;
13011301

1302-
auto CE = dyn_cast<ApplyExpr>(E->getSemanticsProvidingExpr());
1303-
if (!CE)
1304-
return false;
1305-
1306-
// First case -- Optional.none
1307-
if (auto DRE = dyn_cast<DeclRefExpr>(CE->getSemanticFn()))
1308-
return DRE->getDecl() == Ctx.getOptionalNoneDecl();
1302+
if (auto *DSCE = dyn_cast_or_null<DotSyntaxCallExpr>(E->getSemanticsProvidingExpr())) {
1303+
if (auto *DRE = dyn_cast<DeclRefExpr>(DSCE->getSemanticFn()))
1304+
return DRE->getDecl() == Ctx.getOptionalNoneDecl();
1305+
}
13091306

13101307
return false;
13111308
}

0 commit comments

Comments
 (0)