Skip to content

Commit e85d53f

Browse files
Harlan Haskinsrintaro
authored andcommitted
Special-case constructor calls in MiscDiagnostics.
1 parent 12f3d46 commit e85d53f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,18 +1369,18 @@ void swift::fixItAvailableAttrRename(TypeChecker &TC,
13691369
if (parsed.isMember()) {
13701370
diag.fixItReplace(call->getFn()->getSourceRange(), parsed.ContextName);
13711371

1372-
} else {
1373-
auto *dotCall = dyn_cast<DotSyntaxCallExpr>(call->getFn());
1374-
if (!dotCall)
1375-
return;
1376-
1372+
} else if (auto *dotCall = dyn_cast<DotSyntaxCallExpr>(call->getFn())) {
13771373
SourceLoc removeLoc = dotCall->getDotLoc();
13781374
if (removeLoc.isInvalid())
13791375
return;
13801376

13811377
diag.fixItRemove(SourceRange(removeLoc, dotCall->getFn()->getEndLoc()));
1378+
} else if (!isa<ConstructorRefCallExpr>(call->getFn())) {
1379+
return;
13821380
}
13831381

1382+
// Continue on to diagnose any constructor argument label renames.
1383+
13841384
} else {
13851385
// Just replace the base name.
13861386
SmallString<64> baseReplace;

test/1_stdlib/StringDiagnostics_without_Foundation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ func testStringCollectionTypes(s: String) {
2727
struct NotLosslessStringConvertible {}
2828

2929
func testStringInitT() {
30-
_ = String(NotLosslessStringConvertible()) // expected-error{{'init' has been renamed to 'init(describing:)}}
30+
_ = String(NotLosslessStringConvertible()) // expected-error{{'init' has been renamed to 'init(describing:)}}{{14-14=describing: }}
3131
}

0 commit comments

Comments
 (0)