Skip to content

Commit 98a7879

Browse files
committed
swift-api-digester: specify raw types when detecting the reversion of NS_TYPED_EXTENSIBLE_ENUM.
1 parent bea2b71 commit 98a7879

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

test/api-digester/Outputs/apinotes-migrator-gen-revert.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"NodeAnnotation": "RevertSimpleStringRepresentableUpdate",
66
"ChildIndex": "1",
77
"LeftUsr": "c:objc(cs)AnimalStatusDescriptor(cm)animalStatusSingleAttribute:",
8-
"LeftComment": "",
8+
"LeftComment": "AnimalAttributeName",
99
"RightUsr": "",
10-
"RightComment": "",
10+
"RightComment": "String",
1111
"ModuleName": "APINotesTest"
1212
},
1313
{
@@ -27,9 +27,9 @@
2727
"NodeAnnotation": "RevertSimpleOptionalStringRepresentableUpdate",
2828
"ChildIndex": "1",
2929
"LeftUsr": "c:objc(cs)AnimalStatusDescriptor(cm)animalStatusSingleOptionalAttribute:",
30-
"LeftComment": "",
30+
"LeftComment": "AnimalAttributeName",
3131
"RightUsr": "",
32-
"RightComment": "",
32+
"RightComment": "String",
3333
"ModuleName": "APINotesTest"
3434
},
3535
{
@@ -49,9 +49,9 @@
4949
"NodeAnnotation": "RevertDictionaryKeyUpdate",
5050
"ChildIndex": "1",
5151
"LeftUsr": "c:objc(cs)AnimalStatusDescriptor(im)animalStatusDescriptorByAddingAttributes:",
52-
"LeftComment": "",
52+
"LeftComment": "AnimalAttributeName",
5353
"RightUsr": "",
54-
"RightComment": "",
54+
"RightComment": "String",
5555
"ModuleName": "APINotesTest"
5656
},
5757
{
@@ -71,9 +71,9 @@
7171
"NodeAnnotation": "RevertArrayMemberUpdate",
7272
"ChildIndex": "1",
7373
"LeftUsr": "c:objc(cs)AnimalStatusDescriptor(im)animalStatusDescriptorByAddingAttributesArray:",
74-
"LeftComment": "",
74+
"LeftComment": "AnimalAttributeName",
7575
"RightUsr": "",
76-
"RightComment": "",
76+
"RightComment": "String",
7777
"ModuleName": "APINotesTest"
7878
},
7979
{
@@ -93,9 +93,9 @@
9393
"NodeAnnotation": "RevertOptionalDictionaryKeyUpdate",
9494
"ChildIndex": "1",
9595
"LeftUsr": "c:objc(cs)AnimalStatusDescriptor(im)animalStatusDescriptorByAddingOptionalAttributes:",
96-
"LeftComment": "",
96+
"LeftComment": "AnimalAttributeName",
9797
"RightUsr": "",
98-
"RightComment": "",
98+
"RightComment": "String",
9999
"ModuleName": "APINotesTest"
100100
},
101101
{
@@ -115,9 +115,9 @@
115115
"NodeAnnotation": "RevertOptionalArrayMemberUpdate",
116116
"ChildIndex": "1",
117117
"LeftUsr": "c:objc(cs)AnimalStatusDescriptor(im)animalStatusDescriptorByAddingOptionalAttributesArray:",
118-
"LeftComment": "",
118+
"LeftComment": "AnimalAttributeName",
119119
"RightUsr": "",
120-
"RightComment": "",
120+
"RightComment": "String",
121121
"ModuleName": "APINotesTest"
122122
},
123123
{

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2705,7 +2705,8 @@ class InterfaceTypeChangeDetector {
27052705

27062706
bool detectTypeRewritten(SDKNodeType *Node, SDKNodeType *Counter) {
27072707
if (IsVisitingLeft &&
2708-
(Node->getName() != Counter->getName()||
2708+
Node->getPrintedName() != Counter->getPrintedName() &&
2709+
(Node->getName() != Counter->getName() ||
27092710
Node->getChildrenCount() != Counter->getChildrenCount())) {
27102711
Node->annotate(NodeAnnotation::TypeRewritten);
27112712
Node->annotate(NodeAnnotation::TypeRewrittenLeft, Node->getPrintedName());
@@ -2795,6 +2796,8 @@ class InterfaceTypeChangeDetector {
27952796
R->annotate(HasOptional ?
27962797
NodeAnnotation::RevertOptionalDictionaryKeyUpdate :
27972798
NodeAnnotation::RevertDictionaryKeyUpdate);
2799+
R->annotate(NodeAnnotation::RawTypeLeft, KeyChangedTo);
2800+
R->annotate(NodeAnnotation::RawTypeRight, Raw);
27982801
}
27992802
return true;
28002803
}
@@ -2844,6 +2847,8 @@ class InterfaceTypeChangeDetector {
28442847
R->annotate(HasOptional ?
28452848
NodeAnnotation::RevertOptionalArrayMemberUpdate :
28462849
NodeAnnotation::RevertArrayMemberUpdate);
2850+
R->annotate(NodeAnnotation::RawTypeLeft, KeyChangedTo);
2851+
R->annotate(NodeAnnotation::RawTypeRight, Raw);
28472852
}
28482853
return true;
28492854
}
@@ -2875,6 +2880,8 @@ class InterfaceTypeChangeDetector {
28752880
NodeAnnotation::SimpleOptionalStringRepresentableUpdate:
28762881
NodeAnnotation::SimpleStringRepresentableUpdate);
28772882
} else {
2883+
R->annotate(NodeAnnotation::RawTypeLeft, KeyChangedTo);
2884+
R->annotate(NodeAnnotation::RawTypeRight, Raw);
28782885
R->annotate(HasOptional ?
28792886
NodeAnnotation::RevertSimpleOptionalStringRepresentableUpdate:
28802887
NodeAnnotation::RevertSimpleStringRepresentableUpdate);
@@ -3052,6 +3059,12 @@ class DiffItemEmitter : public SDKNodeVisitor {
30523059
case NodeAnnotation::OptionalDictionaryKeyUpdate:
30533060
case NodeAnnotation::SimpleStringRepresentableUpdate:
30543061
case NodeAnnotation::SimpleOptionalStringRepresentableUpdate:
3062+
case NodeAnnotation::RevertArrayMemberUpdate:
3063+
case NodeAnnotation::RevertOptionalArrayMemberUpdate:
3064+
case NodeAnnotation::RevertDictionaryKeyUpdate:
3065+
case NodeAnnotation::RevertOptionalDictionaryKeyUpdate:
3066+
case NodeAnnotation::RevertSimpleStringRepresentableUpdate:
3067+
case NodeAnnotation::RevertSimpleOptionalStringRepresentableUpdate:
30553068
return Node->getAnnotateComment(NodeAnnotation::RawTypeLeft);
30563069
case NodeAnnotation::TypeRewritten:
30573070
return Node->getAnnotateComment(NodeAnnotation::TypeRewrittenLeft);
@@ -3070,6 +3083,12 @@ class DiffItemEmitter : public SDKNodeVisitor {
30703083
case NodeAnnotation::OptionalDictionaryKeyUpdate:
30713084
case NodeAnnotation::SimpleStringRepresentableUpdate:
30723085
case NodeAnnotation::SimpleOptionalStringRepresentableUpdate:
3086+
case NodeAnnotation::RevertArrayMemberUpdate:
3087+
case NodeAnnotation::RevertOptionalArrayMemberUpdate:
3088+
case NodeAnnotation::RevertDictionaryKeyUpdate:
3089+
case NodeAnnotation::RevertOptionalDictionaryKeyUpdate:
3090+
case NodeAnnotation::RevertSimpleStringRepresentableUpdate:
3091+
case NodeAnnotation::RevertSimpleOptionalStringRepresentableUpdate:
30733092
return Node->getAnnotateComment(NodeAnnotation::RawTypeRight);
30743093
case NodeAnnotation::TypeRewritten:
30753094
return Node->getAnnotateComment(NodeAnnotation::TypeRewrittenRight);

0 commit comments

Comments
 (0)