mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Diagnostics] Substring -> String fix-it should be anchored at semantic expressoin
If contextual failure is detected in sub-expression (through type-check call via CSDiag), let's make sure that fix-it is always anchored at semantic expression otherwise it could be attached to the paren representing whole argument list.
This commit is contained in:
@@ -2210,7 +2210,8 @@ bool ContextualFailure::trySequenceSubsequenceFixIts(
|
||||
// Wrap in String.init
|
||||
if (FromType->isEqual(Substring)) {
|
||||
if (ToType->isEqual(String)) {
|
||||
auto range = getAnchor()->getSourceRange();
|
||||
auto *anchor = getAnchor()->getSemanticsProvidingExpr();
|
||||
auto range = anchor->getSourceRange();
|
||||
diagnostic.fixItInsert(range.Start, "String(");
|
||||
diagnostic.fixItInsertAfter(range.End, ")");
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user