File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -4558,10 +4558,16 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
4558
4558
4559
4559
if (callExpr->isImplicit () && overloadName == " ~=" ) {
4560
4560
// This binop was synthesized when typechecking an expression pattern.
4561
- diagnose (lhsExpr->getLoc (),
4562
- diag::cannot_match_expr_pattern_with_value, lhsType, rhsType)
4563
- .highlight (lhsExpr->getSourceRange ())
4564
- .highlight (rhsExpr->getSourceRange ());
4561
+ auto diag = diagnose (lhsExpr->getLoc (),
4562
+ diag::cannot_match_expr_pattern_with_value,
4563
+ lhsType, rhsType);
4564
+ diag.highlight (lhsExpr->getSourceRange ());
4565
+ diag.highlight (rhsExpr->getSourceRange ());
4566
+ if (auto optUnwrappedType = rhsType->getOptionalObjectType ()) {
4567
+ if (lhsType->isEqual (optUnwrappedType)) {
4568
+ diag.fixItInsert (lhsExpr->getEndLoc (), " ?" );
4569
+ }
4570
+ }
4565
4571
return true ;
4566
4572
}
4567
4573
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ case #selector(C1.method1)?:
126
126
}
127
127
128
128
switch optionalSel {
129
- case #selector( SR1827 . bar) : // expected-error{{expression pattern of type 'Selector' cannot match values of type 'Selector?'}}
129
+ case #selector( SR1827 . bar) : // expected-error{{expression pattern of type 'Selector' cannot match values of type 'Selector?'}} {{26-26=?}}
130
130
break
131
131
case #selector( SR1827 . bar) !: // expected-error{{cannot force unwrap value of non-optional type 'Selector'}}
132
132
break
You can’t perform that action at this time.
0 commit comments