Skip to content

Commit 6433bc5

Browse files
committed
migrator: avoid migrating synthesized initializer calls. rdar://40860228
1 parent 55495ec commit 6433bc5

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

lib/Migrator/APIDiffMigratorPass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,8 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
922922
}
923923

924924
bool walkToExprPre(Expr *E) override {
925+
if (E->getSourceRange().isInvalid())
926+
return false;
925927
if (handleQualifiedReplacement(E))
926928
return false;
927929
if (handleAssignDestMigration(E))

test/Migrator/Inputs/string-representable.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,15 @@
216216
"NewPrintedName": "NewAttribute",
217217
"NewTypeName": "AttributeWrapper"
218218
},
219+
{
220+
"DiffItemKind": "CommonDiffItem",
221+
"NodeKind": "Constructor",
222+
"NodeAnnotation": "OptionalDictionaryKeyUpdate",
223+
"ChildIndex": "1",
224+
"LeftUsr": "c:objc(cs)BarForwardDeclaredClass(im)initWithOldLabel0:",
225+
"LeftComment": "Int",
226+
"RightUsr": "",
227+
"RightComment": "AwesomeIntWrapper",
228+
"ModuleName": "bar"
229+
},
219230
]

test/Migrator/string-representable.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// REQUIRES: objc_interop
22
// RUN: %empty-directory(%t.mod)
33
// RUN: %target-swift-frontend -emit-module -o %t.mod/Cities.swiftmodule %S/Inputs/Cities.swift -module-name Cities -parse-as-library
4-
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -I %t.mod -api-diff-data-file %S/Inputs/string-representable.json -emit-migrated-file-path %t/string-representable.swift.result -disable-migrator-fixits -o /dev/null
4+
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -I %t.mod -api-diff-data-file %S/Inputs/string-representable.json -emit-migrated-file-path %t/string-representable.swift.result -disable-migrator-fixits -o /dev/null -F %S/mock-sdk
55
// RUN: diff -u %S/string-representable.swift.expected %t/string-representable.swift.result
66

77
import Cities
8+
import Bar
89

910
func foo(_ c: Container) -> String {
1011
c.Value = ""
@@ -42,3 +43,5 @@ func foo(_ c: Container) -> String {
4243
c.optionalAttrDict = nil
4344
return c.Value
4445
}
46+
47+
class C: BarForwardDeclaredClass {}

test/Migrator/string-representable.swift.expected

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// REQUIRES: objc_interop
22
// RUN: %empty-directory(%t.mod)
33
// RUN: %target-swift-frontend -emit-module -o %t.mod/Cities.swiftmodule %S/Inputs/Cities.swift -module-name Cities -parse-as-library
4-
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -I %t.mod -api-diff-data-file %S/Inputs/string-representable.json -emit-migrated-file-path %t/string-representable.swift.result -disable-migrator-fixits -o /dev/null
4+
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -I %t.mod -api-diff-data-file %S/Inputs/string-representable.json -emit-migrated-file-path %t/string-representable.swift.result -disable-migrator-fixits -o /dev/null -F %S/mock-sdk
55
// RUN: diff -u %S/string-representable.swift.expected %t/string-representable.swift.result
66

77
import Cities
8+
import Bar
89

910
func foo(_ c: Container) -> String {
1011
c.Value = convertToNewAttribute("")
@@ -43,6 +44,8 @@ func foo(_ c: Container) -> String {
4344
return convertFromNewAttribute(c.Value)
4445
}
4546

47+
class C: BarForwardDeclaredClass {}
48+
4649
// Helper function inserted by Swift 4.2 migrator.
4750
fileprivate func convertToNewAttribute(_ input: String) -> NewAttribute {
4851
return NewAttribute(rawValue: input)

0 commit comments

Comments
 (0)