Merge pull request #26376 from xedin/rdar-53238058

[CSFix] Delay `missing unwrap` locator simplification until diagnostic
This commit is contained in:
Pavel Yaskevich
2019-07-29 09:25:43 -07:00
committed by GitHub
6 changed files with 39 additions and 16 deletions

View File

@@ -1085,6 +1085,14 @@ bool MissingOptionalUnwrapFailure::diagnoseAsError() {
auto *anchor = getAnchor();
// If this is an unresolved member expr e.g. `.foo` its
// base type is going to be the same as result type minus
// r-value adjustment because base could be an l-value type.
// We want to fix both cases by only diagnose one of them,
// otherwise this is just going to result in a duplcate diagnostic.
if (getLocator()->isLastElement(ConstraintLocator::UnresolvedMember))
return false;
if (auto assignExpr = dyn_cast<AssignExpr>(anchor))
anchor = assignExpr->getSrc();