Skip to content

Commit 398f483

Browse files
authored
[FixCode] Blacklist the fixit for enum case renames to avoid reverting migrator's change. rdar://27776887 (#4199)
We added the fixit to help users manually migrate enum case references after the declaration has been renamed; however, when interacting with the migrator, the fixit may revert migrator's correct changes, when the migrator updates references before updating the declaration. This patch blacklists the fixit in migrator's pass, so we leave it to users' manually application if necessary.
1 parent 9f46eb5 commit 398f483

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,10 @@ class JSONFixitWriter : public DiagnosticConsumer {
613613
// invalidating some inits with type errors.
614614
if (Info.ID == diag::init_not_instance_member.ID)
615615
return false;
616+
// Renaming enum cases interacts poorly with the swift migrator by
617+
// reverting changes made by the mgirator.
618+
if (Info.ID == diag::could_not_find_enum_case.ID)
619+
return false;
616620

617621
if (Kind == DiagnosticKind::Error)
618622
return true;

test/FixCode/fixits-apply.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,8 @@ protocol Prot2 {
221221
}
222222
class Cls1 : Prot1 {}
223223
func testwhere<T: Prot2 where T.Ty == Cls1>(_: T) {}
224+
225+
enum E {
226+
case abc
227+
}
228+
func testEnumRename() { _ = E.Abc }

test/FixCode/fixits-apply.swift.result

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,8 @@ protocol Prot2 {
224224
}
225225
class Cls1 : Prot1 {}
226226
func testwhere<T: Prot2>(_: T) where T.Ty == Cls1 {}
227+
228+
enum E {
229+
case abc
230+
}
231+
func testEnumRename() { _ = E.Abc }

0 commit comments

Comments
 (0)