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:
Chris Willmore
2015-05-06 19:05:45 +00:00
parent f506d1e0aa
commit f3670d3a6f
2 changed files with 8 additions and 1 deletions

View File

@@ -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(), ")!");