Skip to content

Commit 78271f1

Browse files
committed
swift-module-digester: diagnose self access kind changes for function decls.
1 parent f2bdce8 commit 78271f1

File tree

11 files changed

+115
-60
lines changed

11 files changed

+115
-60
lines changed

include/swift/AST/DiagnosticsModuleDiffer.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ ERROR(no_longer_open,none,"%0 is no longer open for subclassing", (StringRef))
8484

8585
ERROR(func_type_escaping_changed,none,"%0 has %select{removed|added}2 @escaping in %1", (StringRef, StringRef, bool))
8686

87+
ERROR(func_self_access_change,none,"%0 has self access kind changing from %1 to %2", (StringRef, StringRef, StringRef))
88+
8789
#ifndef DIAG_NO_UNDEF
8890
# if defined(DIAG)
8991
# undef DIAG

include/swift/IDE/DigesterEnums.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ KEY_STRING(ModuleName, moduleName)
140140
KEY_STRING(SuperclassUsr, superclassUsr)
141141
KEY_STRING(EnumRawTypeName, enumRawTypeName)
142142
KEY_STRING(GenericSig, genericSig)
143+
KEY_STRING(FuncSelfKind, funcSelfKind)
143144

144145
KEY_STRING_ARR(SuperclassNames, superclassNames)
145146
KEY_STRING_ARR(ConformingProtocols, conformingProtocols)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ cake1: Class C5 is now without @objc
4242
cake1: Enum IceKind is now without @_frozen
4343
cake1: Func C1.foo1() is now not static
4444
cake1: Func C5.dy_foo() is now with dynamic
45-
cake1: Func S1.foo1() is now mutating
45+
cake1: Func S1.foo1() has self access kind changing from NonMutating to Mutating
4646
cake1: Func S1.foo3() is now static
4747
cake1: Struct C6 is now with @_fixed_layout
4848
cake1: Var C1.CIIns1 changes from weak to strong

test/api-digester/Outputs/Cake.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ cake1: Func C7.foo(_:_:) has removed default argument from parameter 1
3434

3535
/* Decl Attribute changes */
3636
cake1: Func C1.foo1() is now not static
37-
cake1: Func S1.foo1() is now mutating
37+
cake1: Func S1.foo1() has self access kind changing from NonMutating to Mutating
3838
cake1: Func S1.foo3() is now static
3939
cake1: Var C1.CIIns1 changes from weak to strong
4040
cake1: Var C1.CIIns2 changes from strong to weak

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

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"usr": "s:4cake2P1PAAE1poiyAaB_pAaB_p_AaB_ptFZ",
3737
"moduleName": "cake",
3838
"genericSig": "<τ_0_0 where τ_0_0 : P1>",
39-
"static": true
39+
"static": true,
40+
"funcSelfKind": "NonMutating"
4041
}
4142
],
4243
"declKind": "Protocol",
@@ -70,7 +71,8 @@
7071
"declKind": "Func",
7172
"usr": "s:4cake2S1V4foo1yyFZ",
7273
"moduleName": "cake",
73-
"static": true
74+
"static": true,
75+
"funcSelfKind": "NonMutating"
7476
},
7577
{
7678
"kind": "Function",
@@ -86,7 +88,7 @@
8688
"declKind": "Func",
8789
"usr": "s:4cake2S1V4foo2yyF",
8890
"moduleName": "cake",
89-
"mutating": true
91+
"funcSelfKind": "Mutating"
9092
},
9193
{
9294
"kind": "Function",
@@ -101,7 +103,8 @@
101103
],
102104
"declKind": "Func",
103105
"usr": "s:4cake2S1V4foo6yyF",
104-
"moduleName": "cake"
106+
"moduleName": "cake",
107+
"funcSelfKind": "NonMutating"
105108
},
106109
{
107110
"kind": "Constructor",
@@ -188,7 +191,8 @@
188191
"declKind": "Func",
189192
"usr": "s:4cake2C0CA2A2S1VRszAERs_AERs0_rlE17conditionalFooExtyyF",
190193
"moduleName": "cake",
191-
"genericSig": "<τ_0_0, τ_0_1, τ_0_2 where τ_0_0 == S1, τ_0_1 == S1, τ_0_2 == S1>"
194+
"genericSig": "<τ_0_0, τ_0_1, τ_0_2 where τ_0_0 == S1, τ_0_1 == S1, τ_0_2 == S1>",
195+
"funcSelfKind": "NonMutating"
192196
},
193197
{
194198
"kind": "Function",
@@ -204,7 +208,8 @@
204208
"declKind": "Func",
205209
"usr": "s:4cake2C0C19unconditionalFooExtyyF",
206210
"moduleName": "cake",
207-
"genericSig": "<τ_0_0, τ_0_1, τ_0_2>"
211+
"genericSig": "<τ_0_0, τ_0_1, τ_0_2>",
212+
"funcSelfKind": "NonMutating"
208213
}
209214
],
210215
"declKind": "Class",
@@ -231,7 +236,8 @@
231236
"declKind": "Func",
232237
"usr": "s:4cake2C1C4foo1yyFZ",
233238
"moduleName": "cake",
234-
"static": true
239+
"static": true,
240+
"funcSelfKind": "NonMutating"
235241
},
236242
{
237243
"kind": "Var",
@@ -435,7 +441,8 @@
435441
],
436442
"declKind": "Func",
437443
"usr": "s:4cake4foo1_1bySi_AA2S1VtF",
438-
"moduleName": "cake"
444+
"moduleName": "cake",
445+
"funcSelfKind": "NonMutating"
439446
},
440447
{
441448
"kind": "Function",
@@ -463,7 +470,8 @@
463470
],
464471
"declKind": "Func",
465472
"usr": "s:4cake4foo2_1bySi_AA2S1VtF",
466-
"moduleName": "cake"
473+
"moduleName": "cake",
474+
"funcSelfKind": "NonMutating"
467475
},
468476
{
469477
"kind": "TypeDecl",
@@ -561,7 +569,8 @@
561569
"declKind": "Func",
562570
"usr": "s:4cake6NumberO4hash4intoys6HasherVz_tF",
563571
"moduleName": "cake",
564-
"implicit": true
572+
"implicit": true,
573+
"funcSelfKind": "NonMutating"
565574
},
566575
{
567576
"kind": "Constructor",
@@ -678,7 +687,8 @@
678687
],
679688
"declKind": "Func",
680689
"usr": "s:4cake4foo3yySDySiSSGF",
681-
"moduleName": "cake"
690+
"moduleName": "cake",
691+
"funcSelfKind": "NonMutating"
682692
},
683693
{
684694
"kind": "TypeDecl",
@@ -739,8 +749,7 @@
739749
"implicit": true,
740750
"declAttributes": [
741751
"Transparent"
742-
],
743-
"mutating": true
752+
]
744753
}
745754
],
746755
"declKind": "Var",
@@ -988,7 +997,8 @@
988997
"declKind": "Func",
989998
"usr": "s:4cake21ProWithAssociatedTypePAAE10NonReqFuncyyF",
990999
"moduleName": "cake",
991-
"genericSig": "<τ_0_0 where τ_0_0 : ProWithAssociatedType>"
1000+
"genericSig": "<τ_0_0 where τ_0_0 : ProWithAssociatedType>",
1001+
"funcSelfKind": "NonMutating"
9921002
},
9931003
{
9941004
"kind": "Var",
@@ -1116,7 +1126,8 @@
11161126
"usr": "s:4cake6PSuperP3fooyyF",
11171127
"moduleName": "cake",
11181128
"genericSig": "<τ_0_0 where τ_0_0 : PSuper>",
1119-
"protocolReq": true
1129+
"protocolReq": true,
1130+
"funcSelfKind": "NonMutating"
11201131
}
11211132
],
11221133
"declKind": "Protocol",
@@ -1157,7 +1168,8 @@
11571168
"overriding": true,
11581169
"declAttributes": [
11591170
"Override"
1160-
]
1171+
],
1172+
"funcSelfKind": "NonMutating"
11611173
}
11621174
],
11631175
"declKind": "Protocol",
@@ -1248,7 +1260,8 @@
12481260
],
12491261
"declKind": "Func",
12501262
"usr": "s:Si4cakeE3fooyyF",
1251-
"moduleName": "cake"
1263+
"moduleName": "cake",
1264+
"funcSelfKind": "NonMutating"
12521265
},
12531266
{
12541267
"kind": "Function",
@@ -1263,7 +1276,8 @@
12631276
],
12641277
"declKind": "Func",
12651278
"usr": "s:Si4cakeE3baryyF",
1266-
"moduleName": "cake"
1279+
"moduleName": "cake",
1280+
"funcSelfKind": "NonMutating"
12671281
}
12681282
],
12691283
"declKind": "Struct",

test/api-digester/Outputs/cake.json

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"usr": "s:4cake2P1PAAE1poiyAaB_pAaB_p_AaB_ptFZ",
3737
"moduleName": "cake",
3838
"genericSig": "<Self where Self : P1>",
39-
"static": true
39+
"static": true,
40+
"funcSelfKind": "NonMutating"
4041
}
4142
],
4243
"declKind": "Protocol",
@@ -70,7 +71,8 @@
7071
"declKind": "Func",
7172
"usr": "s:4cake2S1V4foo1yyFZ",
7273
"moduleName": "cake",
73-
"static": true
74+
"static": true,
75+
"funcSelfKind": "NonMutating"
7476
},
7577
{
7678
"kind": "Function",
@@ -86,7 +88,7 @@
8688
"declKind": "Func",
8789
"usr": "s:4cake2S1V4foo2yyF",
8890
"moduleName": "cake",
89-
"mutating": true
91+
"funcSelfKind": "Mutating"
9092
},
9193
{
9294
"kind": "Function",
@@ -108,7 +110,8 @@
108110
],
109111
"declKind": "Func",
110112
"usr": "s:4cake2S1V4foo6yyF",
111-
"moduleName": "cake"
113+
"moduleName": "cake",
114+
"funcSelfKind": "NonMutating"
112115
},
113116
{
114117
"kind": "Constructor",
@@ -195,7 +198,8 @@
195198
"declKind": "Func",
196199
"usr": "s:4cake2C0CA2A2S1VRszAERs_AERs0_rlE17conditionalFooExtyyF",
197200
"moduleName": "cake",
198-
"genericSig": "<T1, T2, T3 where T1 == S1, T2 == S1, T3 == S1>"
201+
"genericSig": "<T1, T2, T3 where T1 == S1, T2 == S1, T3 == S1>",
202+
"funcSelfKind": "NonMutating"
199203
},
200204
{
201205
"kind": "Function",
@@ -211,7 +215,8 @@
211215
"declKind": "Func",
212216
"usr": "s:4cake2C0C19unconditionalFooExtyyF",
213217
"moduleName": "cake",
214-
"genericSig": "<T1, T2, T3>"
218+
"genericSig": "<T1, T2, T3>",
219+
"funcSelfKind": "NonMutating"
215220
}
216221
],
217222
"declKind": "Class",
@@ -275,7 +280,8 @@
275280
"usr": "s:4cake2C1C4foo1yyFZ",
276281
"moduleName": "cake",
277282
"static": true,
278-
"isOpen": true
283+
"isOpen": true,
284+
"funcSelfKind": "NonMutating"
279285
},
280286
{
281287
"kind": "Var",
@@ -479,7 +485,8 @@
479485
],
480486
"declKind": "Func",
481487
"usr": "s:4cake4foo1_1bySi_AA2S1VtF",
482-
"moduleName": "cake"
488+
"moduleName": "cake",
489+
"funcSelfKind": "NonMutating"
483490
},
484491
{
485492
"kind": "Function",
@@ -507,7 +514,8 @@
507514
],
508515
"declKind": "Func",
509516
"usr": "s:4cake4foo2_1bySi_AA2S1VtF",
510-
"moduleName": "cake"
517+
"moduleName": "cake",
518+
"funcSelfKind": "NonMutating"
511519
},
512520
{
513521
"kind": "TypeDecl",
@@ -629,7 +637,8 @@
629637
"declKind": "Func",
630638
"usr": "s:4cake6NumberO4hash4intoys6HasherVz_tF",
631639
"moduleName": "cake",
632-
"implicit": true
640+
"implicit": true,
641+
"funcSelfKind": "NonMutating"
633642
},
634643
{
635644
"kind": "Constructor",
@@ -746,7 +755,8 @@
746755
],
747756
"declKind": "Func",
748757
"usr": "s:4cake4foo3yySDySiSSGF",
749-
"moduleName": "cake"
758+
"moduleName": "cake",
759+
"funcSelfKind": "NonMutating"
750760
},
751761
{
752762
"kind": "TypeDecl",
@@ -807,8 +817,7 @@
807817
"implicit": true,
808818
"declAttributes": [
809819
"Transparent"
810-
],
811-
"mutating": true
820+
]
812821
}
813822
],
814823
"declKind": "Var",
@@ -927,7 +936,8 @@
927936
"declKind": "Func",
928937
"usr": "s:4cake21ProWithAssociatedTypePAAE10NonReqFuncyyF",
929938
"moduleName": "cake",
930-
"genericSig": "<Self where Self : ProWithAssociatedType>"
939+
"genericSig": "<Self where Self : ProWithAssociatedType>",
940+
"funcSelfKind": "NonMutating"
931941
},
932942
{
933943
"kind": "Var",
@@ -1072,7 +1082,8 @@
10721082
"usr": "s:4cake6PSuperP3fooyyF",
10731083
"moduleName": "cake",
10741084
"genericSig": "<Self where Self : PSuper>",
1075-
"protocolReq": true
1085+
"protocolReq": true,
1086+
"funcSelfKind": "NonMutating"
10761087
}
10771088
],
10781089
"declKind": "Protocol",
@@ -1113,7 +1124,8 @@
11131124
"overriding": true,
11141125
"declAttributes": [
11151126
"Override"
1116-
]
1127+
],
1128+
"funcSelfKind": "NonMutating"
11171129
}
11181130
],
11191131
"declKind": "Protocol",
@@ -1173,7 +1185,8 @@
11731185
],
11741186
"declKind": "Func",
11751187
"usr": "s:Si4cakeE3fooyyF",
1176-
"moduleName": "cake"
1188+
"moduleName": "cake",
1189+
"funcSelfKind": "NonMutating"
11771190
},
11781191
{
11791192
"kind": "Function",
@@ -1188,7 +1201,8 @@
11881201
],
11891202
"declKind": "Func",
11901203
"usr": "s:Si4cakeE3baryyF",
1191-
"moduleName": "cake"
1204+
"moduleName": "cake",
1205+
"funcSelfKind": "NonMutating"
11921206
}
11931207
],
11941208
"declKind": "Struct",

test/api-digester/Outputs/clang-module-dump.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"isOpen": true,
3333
"declAttributes": [
3434
"ObjC"
35-
]
35+
],
36+
"funcSelfKind": "NonMutating"
3637
},
3738
{
3839
"kind": "Constructor",
@@ -103,7 +104,8 @@
103104
"protocolReq": true,
104105
"declAttributes": [
105106
"ObjC"
106-
]
107+
],
108+
"funcSelfKind": "NonMutating"
107109
}
108110
],
109111
"declKind": "Protocol",

0 commit comments

Comments
 (0)