File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -6636,8 +6636,12 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
6636
6636
}
6637
6637
6638
6638
// Except for forced cast expressions, if optionals are more than a single
6639
- // level difference, we don't need to record any fix.
6640
- if (!isExpr<ForcedCheckedCastExpr>(anchor) && extraOptionals > 1 )
6639
+ // level difference or there is a single level between the types but an extra
6640
+ // level of optional is added to subexpr via OptionalEvaluationExpr, we don't
6641
+ // need to record any fix.
6642
+ if (!isExpr<ForcedCheckedCastExpr>(anchor) &&
6643
+ (extraOptionals > 1 ||
6644
+ isExpr<OptionalEvaluationExpr>(castExpr->getSubExpr ())))
6641
6645
return nullptr ;
6642
6646
6643
6647
// Always succeed
Original file line number Diff line number Diff line change @@ -535,3 +535,17 @@ protocol PP2: PP1 { }
535
535
extension Optional : PP1 where Wrapped == PP2 { }
536
536
537
537
nil is PP1 // expected-error {{'nil' requires a contextual type}}
538
+
539
+ // SR-15039
540
+ enum ChangeType < T> {
541
+ case initial( T )
542
+ case delta( previous: T , next: T )
543
+ case unset
544
+
545
+ var delta : ( previous: T ? , next: T ) ? { nil }
546
+ }
547
+
548
+ extension ChangeType where T == String ? {
549
+ var foo : String ? { return self . delta? . previous as? String } // OK
550
+ var bar : String ? { self . delta? . next }
551
+ }
You can’t perform that action at this time.
0 commit comments