Skip to content

Commit 2686217

Browse files
authored
Merge pull request #19477 from nkcsgexi/subscript-digester
swift-module-digester: include SubscriptDecl in the Json dump.
2 parents 9ce81df + 5fbecfa commit 2686217

File tree

13 files changed

+248
-64
lines changed

13 files changed

+248
-64
lines changed

include/swift/AST/DiagnosticsModuleDiffer.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ ERROR(raw_type_change,none,"%0(%1) is now %2 representable", (StringRef, StringR
4242

4343
ERROR(removed_decl,none,"%0 has been removed%select{| (deprecated)}1", (StringRef, bool))
4444

45+
ERROR(removed_setter,none,"%0 has removed its setter", (StringRef))
46+
4547
ERROR(moved_decl,none,"%0 has been moved to %1", (StringRef, StringRef))
4648

4749
ERROR(renamed_decl,none,"%0 has been renamed to %1", (StringRef, StringRef))

include/swift/IDE/DigesterEnums.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ NODE_KIND(DeclSetter, Setter)
4646
NODE_KIND(DeclVar, Var)
4747
NODE_KIND(DeclTypeAlias, TypeAlias)
4848
NODE_KIND(DeclAssociatedType, AssociatedType)
49+
NODE_KIND(DeclSubscript, Subscript)
4950

5051
NODE_ANNOTATION(Added)
5152
NODE_ANNOTATION(Removed)
@@ -112,6 +113,7 @@ KEY(conformingProtocols)
112113
KEY(enumRawTypeName)
113114
KEY(genericSig)
114115
KEY(fixedbinaryorder)
116+
KEY(hasSetter)
115117

116118
KNOWN_TYPE(Optional)
117119
KNOWN_TYPE(ImplicitlyUnwrappedOptional)

test/api-digester/Inputs/cake.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,9 @@ extension Int: P1 { public func bar() {} }
5454
public protocol ProWithAssociatedType {
5555
associatedtype A
5656
associatedtype B = Int
57-
}
57+
}
58+
59+
public protocol SubsContainer {
60+
subscript(getter i: Int) -> Int { get }
61+
subscript(setter i: Int) -> Int { get set }
62+
}

test/api-digester/Inputs/cake1.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,11 @@ public protocol AssociatedTypePro {
7575
associatedtype T2
7676
associatedtype T3 = C1
7777
}
78+
79+
public class RemoveSetters {
80+
public var Value = 4
81+
public subscript(_ idx: Int) -> Int {
82+
get { return 1 }
83+
set(newValue) {}
84+
}
85+
}

test/api-digester/Inputs/cake2.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,11 @@ public protocol AssociatedTypePro {
8282
associatedtype T2
8383
associatedtype T3 = C6
8484
}
85+
86+
public class RemoveSetters {
87+
public private(set) var Value = 4
88+
public subscript(_ idx: Int) -> Int {
89+
get { return 1 }
90+
}
91+
}
92+

test/api-digester/Outputs/Cake-abi.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ cake1: Protocol P3 has generic signature change from <τ_0_0 : P1, τ_0_0 : P2>
99
cake1: Constructor Somestruct2.init(_:) has been removed
1010
cake1: Constructor fixedLayoutStruct.init(b:a:) has been removed
1111
cake1: Func C4.foo() has been removed
12+
cake1: Subscript RemoveSetters.subscript(_:) has removed its setter
13+
cake1: Var RemoveSetters.Value has removed its setter
1214

1315
/* Moved Decls */
1416

test/api-digester/Outputs/Cake.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ cake1: Protocol P3 has generic signature change from <Self : P1, Self : P2> to <
99
cake1: Constructor Somestruct2.init(_:) has been removed
1010
cake1: Constructor fixedLayoutStruct.init(b:a:) has been removed
1111
cake1: Func C4.foo() has been removed
12+
cake1: Subscript RemoveSetters.subscript(_:) has removed its setter
13+
cake1: Var RemoveSetters.Value has removed its setter
1214

1315
/* Moved Decls */
1416

test/api-digester/Outputs/cake-abi.json

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -808,33 +808,6 @@
808808
"usr": "s:Si"
809809
}
810810
]
811-
},
812-
{
813-
"kind": "Setter",
814-
"name": "_",
815-
"printedName": "_()",
816-
"declKind": "Accessor",
817-
"usr": "s:4cake17fixedLayoutStructV1b33_3D8926C30F7417F2EF9A277D0C73FBDBLLSivs",
818-
"location": "",
819-
"moduleName": "cake",
820-
"implicit": true,
821-
"mutating": true,
822-
"declAttributes": [
823-
"Transparent"
824-
],
825-
"children": [
826-
{
827-
"kind": "TypeNominal",
828-
"name": "Void",
829-
"printedName": "()"
830-
},
831-
{
832-
"kind": "TypeNominal",
833-
"name": "Int",
834-
"printedName": "Int",
835-
"usr": "s:Si"
836-
}
837-
]
838811
}
839812
]
840813
},
@@ -877,33 +850,6 @@
877850
"usr": "s:Si"
878851
}
879852
]
880-
},
881-
{
882-
"kind": "Setter",
883-
"name": "_",
884-
"printedName": "_()",
885-
"declKind": "Accessor",
886-
"usr": "s:4cake17fixedLayoutStructV1cSivs",
887-
"location": "",
888-
"moduleName": "cake",
889-
"implicit": true,
890-
"mutating": true,
891-
"declAttributes": [
892-
"Transparent"
893-
],
894-
"children": [
895-
{
896-
"kind": "TypeNominal",
897-
"name": "Void",
898-
"printedName": "()"
899-
},
900-
{
901-
"kind": "TypeNominal",
902-
"name": "Int",
903-
"printedName": "Int",
904-
"usr": "s:Si"
905-
}
906-
]
907853
}
908854
]
909855
},
@@ -1000,6 +946,66 @@
1000946
}
1001947
]
1002948
},
949+
{
950+
"kind": "TypeDecl",
951+
"name": "SubsContainer",
952+
"printedName": "SubsContainer",
953+
"declKind": "Protocol",
954+
"usr": "s:4cake13SubsContainerP",
955+
"location": "",
956+
"moduleName": "cake",
957+
"children": [
958+
{
959+
"kind": "Subscript",
960+
"name": "subscript",
961+
"printedName": "subscript(getter:)",
962+
"declKind": "Subscript",
963+
"usr": "s:4cake13SubsContainerP6getterS2i_tcip",
964+
"location": "",
965+
"moduleName": "cake",
966+
"genericSig": "<τ_0_0 where τ_0_0 : SubsContainer>",
967+
"children": [
968+
{
969+
"kind": "TypeNominal",
970+
"name": "Int",
971+
"printedName": "Int",
972+
"usr": "s:Si"
973+
},
974+
{
975+
"kind": "TypeNominal",
976+
"name": "Int",
977+
"printedName": "Int",
978+
"usr": "s:Si"
979+
}
980+
]
981+
},
982+
{
983+
"kind": "Subscript",
984+
"name": "subscript",
985+
"printedName": "subscript(setter:)",
986+
"declKind": "Subscript",
987+
"usr": "s:4cake13SubsContainerP6setterS2i_tcip",
988+
"location": "",
989+
"moduleName": "cake",
990+
"genericSig": "<τ_0_0 where τ_0_0 : SubsContainer>",
991+
"hasSetter": true,
992+
"children": [
993+
{
994+
"kind": "TypeNominal",
995+
"name": "Int",
996+
"printedName": "Int",
997+
"usr": "s:Si"
998+
},
999+
{
1000+
"kind": "TypeNominal",
1001+
"name": "Int",
1002+
"printedName": "Int",
1003+
"usr": "s:Si"
1004+
}
1005+
]
1006+
}
1007+
]
1008+
},
10031009
{
10041010
"kind": "TypeDecl",
10051011
"name": "Int",

test/api-digester/Outputs/cake.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,66 @@
876876
}
877877
]
878878
},
879+
{
880+
"kind": "TypeDecl",
881+
"name": "SubsContainer",
882+
"printedName": "SubsContainer",
883+
"declKind": "Protocol",
884+
"usr": "s:4cake13SubsContainerP",
885+
"location": "",
886+
"moduleName": "cake",
887+
"children": [
888+
{
889+
"kind": "Subscript",
890+
"name": "subscript",
891+
"printedName": "subscript(getter:)",
892+
"declKind": "Subscript",
893+
"usr": "s:4cake13SubsContainerP6getterS2i_tcip",
894+
"location": "",
895+
"moduleName": "cake",
896+
"genericSig": "<Self where Self : SubsContainer>",
897+
"children": [
898+
{
899+
"kind": "TypeNominal",
900+
"name": "Int",
901+
"printedName": "Int",
902+
"usr": "s:Si"
903+
},
904+
{
905+
"kind": "TypeNominal",
906+
"name": "Int",
907+
"printedName": "Int",
908+
"usr": "s:Si"
909+
}
910+
]
911+
},
912+
{
913+
"kind": "Subscript",
914+
"name": "subscript",
915+
"printedName": "subscript(setter:)",
916+
"declKind": "Subscript",
917+
"usr": "s:4cake13SubsContainerP6setterS2i_tcip",
918+
"location": "",
919+
"moduleName": "cake",
920+
"genericSig": "<Self where Self : SubsContainer>",
921+
"hasSetter": true,
922+
"children": [
923+
{
924+
"kind": "TypeNominal",
925+
"name": "Int",
926+
"printedName": "Int",
927+
"usr": "s:Si"
928+
},
929+
{
930+
"kind": "TypeNominal",
931+
"name": "Int",
932+
"printedName": "Int",
933+
"usr": "s:Si"
934+
}
935+
]
936+
}
937+
]
938+
},
879939
{
880940
"kind": "TypeDecl",
881941
"name": "Int",

0 commit comments

Comments
 (0)