mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
When adding '!' in fix-it, make sure that it doesn't fall into the
optional evaluation context that produced the optional. <rdar://problem/20377684> Oscillating fixit for optional chain calling method that returns non-optional Swift SVN r28212
This commit is contained in:
@@ -5905,7 +5905,8 @@ Expr *ConstraintSystem::applySolution(Solution &solution, Expr *expr,
|
||||
auto diag = TC.diagnose(affected->getLoc(),
|
||||
diag::missing_unwrap_optional, type);
|
||||
bool parensNeeded = (getInfixData(DC, affected).getPrecedence() <
|
||||
IntrinsicPrecedences::PostfixUnaryExpr);
|
||||
IntrinsicPrecedences::PostfixUnaryExpr) ||
|
||||
isa<OptionalEvaluationExpr>(affected);
|
||||
if (parensNeeded) {
|
||||
diag.fixItInsert(affected->getStartLoc(), "(")
|
||||
.fixItInsertAfter(affected->getEndLoc(), ")!");
|
||||
|
||||
Reference in New Issue
Block a user