mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CSDiagnostics] Handle CoercionExpr empty path in ContextualMismatch
This commit is contained in:
@@ -1854,6 +1854,22 @@ bool ContextualFailure::diagnoseAsError() {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (auto *coerceExpr = dyn_cast<CoerceExpr>(anchor)) {
|
||||
auto fromType = getFromType();
|
||||
auto toType = getType(coerceExpr->getCastTypeLoc());
|
||||
auto diagnostic =
|
||||
getDiagnosticFor(CTP_CoerceOperand,
|
||||
/*forProtocol=*/toType->isAnyExistentialType());
|
||||
|
||||
auto diag =
|
||||
emitDiagnostic(anchor->getLoc(), *diagnostic, fromType, toType);
|
||||
diag.highlight(anchor->getSourceRange());
|
||||
|
||||
(void)tryFixIts(diag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user