diff --git a/lib/Migrator/APIDiffMigratorPass.cpp b/lib/Migrator/APIDiffMigratorPass.cpp index 31c8fcfe3807d..13a7e8a41b180 100644 --- a/lib/Migrator/APIDiffMigratorPass.cpp +++ b/lib/Migrator/APIDiffMigratorPass.cpp @@ -1404,6 +1404,19 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker { D->walk(Removal); } } + + // Handle property overriding migration. + if (auto *VD = dyn_cast(D)) { + for (auto *Item: getRelatedDiffItems(VD)) { + if (auto *CD = dyn_cast(Item)) { + // If the overriden property has been renamed, we should rename + // this property decl as well. + if (CD->isRename() && VD->getNameLoc().isValid()) { + Editor.replaceToken(VD->getNameLoc(), CD->getNewName()); + } + } + } + } return true; } }; diff --git a/test/Migrator/Inputs/API.json b/test/Migrator/Inputs/API.json index 47ed41ec4e882..f44b1f4aa6221 100644 --- a/test/Migrator/Inputs/API.json +++ b/test/Migrator/Inputs/API.json @@ -539,5 +539,16 @@ "RightUsr": "", "RightComment": "FontWeighting", "ModuleName": "Cities" - } + }, + { + "DiffItemKind": "CommonDiffItem", + "NodeKind": "Var", + "NodeAnnotation": "Rename", + "ChildIndex": "0", + "LeftUsr": "s:6CitiesAAC6yogurtSivp", + "LeftComment": "yogurt", + "RightUsr": "", + "RightComment": "cheese", + "ModuleName": "Cities" + }, ] diff --git a/test/Migrator/Inputs/Cities.swift b/test/Migrator/Inputs/Cities.swift index 8be42c84d5bef..d3191c2668274 100644 --- a/test/Migrator/Inputs/Cities.swift +++ b/test/Migrator/Inputs/Cities.swift @@ -9,6 +9,7 @@ open class Cities { open func buderim() -> Cities? { return Cities(x: 1) } open func noosa() -> [[String : Cities]?] { return [] } open func maroochy(x: Int?, y: Int?) {} + open var yogurt: Int { return 1 } public struct CityKind { public static let Town = 1 public static let Village = 1 diff --git a/test/Migrator/rename-func-decl.swift b/test/Migrator/rename-func-decl.swift index 3d4c943d9a8a7..2adb46a7e7264 100644 --- a/test/Migrator/rename-func-decl.swift +++ b/test/Migrator/rename-func-decl.swift @@ -18,3 +18,7 @@ class MySubTopLevelType: ToplevelType { class MySubTopLevelType2: ToplevelType { override func member(_ x: @escaping (((([(Any)])?))) -> Void) {} } + +class SubCities: Cities { + override var yogurt: Int { return 2 } +} diff --git a/test/Migrator/rename-func-decl.swift.expected b/test/Migrator/rename-func-decl.swift.expected index 5c7e94a2fd374..235692f57cb0f 100644 --- a/test/Migrator/rename-func-decl.swift.expected +++ b/test/Migrator/rename-func-decl.swift.expected @@ -18,3 +18,7 @@ class MySubTopLevelType: ToplevelType { class MySubTopLevelType2: ToplevelType { override func member(_ x: @escaping (((([(Int)])?))) -> Void) {} } + +class SubCities: Cities { + override var cheese: Int { return 2 } +}