Skip to content

Commit 55843a2

Browse files
authored
migrator: compare sub-kind when checking if two diff items are equivalent to avoid dropping information. rdar://32431567
1 parent db32480 commit 55843a2

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

lib/IDE/APIDigesterData.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ bool APIDiffItem::operator==(const APIDiffItem &Other) const {
251251
case APIDiffItemKind::ADK_CommonDiffItem: {
252252
auto *Left = static_cast<const CommonDiffItem*>(this);
253253
auto *Right = static_cast<const CommonDiffItem*>(&Other);
254-
return Left->ChildIndex == Right->ChildIndex;
254+
return
255+
Left->DiffKind == Right->DiffKind &&
256+
Left->ChildIndex == Right->ChildIndex;
255257
}
256258
case APIDiffItemKind::ADK_NoEscapeFuncParam: {
257259
auto *Left = static_cast<const NoEscapeFuncParam*>(this);

test/Migrator/API.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,28 @@
2828
"RightComment": "barGlobalFuncNewName(newlabel:)",
2929
"ModuleName": "bar"
3030
},
31+
{
32+
"DiffItemKind": "CommonDiffItem",
33+
"NodeKind": "Function",
34+
"NodeAnnotation": "WrapOptional",
35+
"ChildIndex": "0",
36+
"LeftUsr": "c:objc(cs)PropertyUserInterface(cm)methodPlus",
37+
"LeftComment": "",
38+
"RightUsr": "",
39+
"RightComment": "",
40+
"ModuleName": "bar"
41+
},
42+
{
43+
"DiffItemKind": "CommonDiffItem",
44+
"NodeKind": "Function",
45+
"NodeAnnotation": "Rename",
46+
"ChildIndex": "0",
47+
"LeftUsr": "c:objc(cs)PropertyUserInterface(cm)methodPlus",
48+
"LeftComment": "",
49+
"RightUsr": "",
50+
"RightComment": "newMethodPlus()",
51+
"ModuleName": "bar"
52+
},
3153
{
3254
"DiffItemKind": "CommonDiffItem",
3355
"NodeKind": "Function",

test/Migrator/mock-sdk/Bar.framework/Headers/Bar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ enum BarForwardDeclaredEnum {
2626
- (void) setField:(int)info;
2727
+ (int) fieldPlus;
2828
+ (void) methodPlus:(int)info;
29+
+ (void) methodPlus;
2930
@end
3031

3132
#define BAR_MACRO_1 0

test/Migrator/rename.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func foo(_ b: BarForwardDeclaredClass) {
1616
b.barInstanceFunc1(0, anotherValue: 1, anotherValue1: 2, anotherValue2: 3)
1717
barGlobalFuncOldName(2)
1818
_ = barGlobalVariableOldEnumElement
19+
_ = PropertyUserInterface.methodPlus()
1920
}
2021

2122
func foo1(_ b: BarForwardDeclaredClass) {

test/Migrator/rename.swift.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func foo(_ b: BarForwardDeclaredClass) {
1616
b.barNewInstanceFunc1(newlabel1: 0, newlabel2: 1, newlabel3: 2, newlabel4: 3)
1717
barGlobalFuncNewName(newlabel: 2)
1818
_ = NewEnum.enumElement
19+
_ = PropertyUserInterface.newMethodPlus()
1920
}
2021

2122
func foo1(_ b: BarForwardDeclaredClass) {

0 commit comments

Comments
 (0)