mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Speculatively fix optionals by unwrapping them with '!'.
Example:
test/Constraints/fixes.swift:54:9: error: value of optional type 'B?'
not unwrapped; did you mean to use '!' or '?'?
b = a as B
^
!
Swift SVN r16938
This commit is contained in:
@@ -3853,6 +3853,23 @@ Expr *ConstraintSystem::applySolution(const Solution &solution,
|
||||
diagnosed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case ExprFixKind::ForceOptional:
|
||||
case ExprFixKind::ForceDowncast: {
|
||||
auto type = solution.simplifyType(TC, affected->getType())
|
||||
->getRValueType();
|
||||
SourceLoc afterAffectedLoc
|
||||
= Lexer::getLocForEndOfToken(TC.Context.SourceMgr,
|
||||
affected->getEndLoc());
|
||||
TC.diagnose(affected->getLoc(),
|
||||
fix.first == ExprFixKind::ForceOptional
|
||||
? diag::missing_unwrap_optional
|
||||
: diag::missing_forced_downcast,
|
||||
type)
|
||||
.fixItInsert(afterAffectedLoc, "!");
|
||||
diagnosed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user