File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -901,9 +901,10 @@ bool MemberAccessOnOptionalBaseFailure::diagnoseAsError() {
901
901
902
902
void MissingOptionalUnwrapFailure::offerDefaultValueUnwrapFixIt (
903
903
DeclContext *DC, Expr *expr) const {
904
- auto *anchor = getAnchor ( );
904
+ assert (expr );
905
905
906
- // If anchor is an explicit address-of, or expression which produces
906
+ auto *anchor = getAnchor ();
907
+ // If anchor is n explicit address-of, or expression which produces
907
908
// an l-value (e.g. first argument of `+=` operator), let's not
908
909
// suggest default value here because that would produce r-value type.
909
910
if (isa<InOutExpr>(anchor))
@@ -1047,7 +1048,10 @@ bool MissingOptionalUnwrapFailure::diagnoseAsError() {
1047
1048
if (singleUse && binding && binding->getNumPatternEntries () == 1 &&
1048
1049
varDecl->getTypeSourceRangeForDiagnostics ().isInvalid ()) {
1049
1050
1050
- Expr *initializer = varDecl->getParentInitializer ();
1051
+ auto *initializer = varDecl->getParentInitializer ();
1052
+ if (!initializer)
1053
+ return true ;
1054
+
1051
1055
if (auto declRefExpr = dyn_cast<DeclRefExpr>(initializer)) {
1052
1056
if (declRefExpr->getDecl ()
1053
1057
->getAttrs ()
You can’t perform that action at this time.
0 commit comments