File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -1152,18 +1152,21 @@ namespace {
1152
1152
// `_ = nil`, let's diagnose it here because solver can't
1153
1153
// attempt any types for it.
1154
1154
auto *parentExpr = CS.getParentExpr (expr);
1155
- if (auto *PE = dyn_cast <ParenExpr>(parentExpr))
1155
+ if (parentExpr && isa <ParenExpr>(parentExpr))
1156
1156
parentExpr = CS.getParentExpr (parentExpr);
1157
1157
1158
- if (isa<ForceValueExpr>(parentExpr)) {
1159
- DE.diagnose (expr->getLoc (), diag::cannot_force_unwrap_nil_literal);
1160
- return Type ();
1161
- }
1158
+ if (parentExpr) {
1159
+ // `_ = nil!`
1160
+ if (isa<ForceValueExpr>(parentExpr)) {
1161
+ DE.diagnose (expr->getLoc (), diag::cannot_force_unwrap_nil_literal);
1162
+ return Type ();
1163
+ }
1162
1164
1163
- if (isa<NilLiteralExpr>(parentExpr)
1164
- || isa<OptionalEvaluationExpr>(parentExpr)) {
1165
- DE.diagnose (expr->getLoc (), diag::unresolved_nil_literal);
1166
- return Type ();
1165
+ // `_ = nil?`
1166
+ if (isa<OptionalEvaluationExpr>(parentExpr)) {
1167
+ DE.diagnose (expr->getLoc (), diag::unresolved_nil_literal);
1168
+ return Type ();
1169
+ }
1167
1170
}
1168
1171
1169
1172
// `_ = nil`
You can’t perform that action at this time.
0 commit comments