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(
66366636 }
66376637
66386638 // 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 ())))
66416645 return nullptr ;
66426646
66436647 // Always succeed
Original file line number Diff line number Diff line change @@ -535,3 +535,17 @@ protocol PP2: PP1 { }
535535extension Optional : PP1 where Wrapped == PP2 { }
536536
537537nil 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