Skip to content

Commit 29e0379

Browse files
authored
Fully qualify types introduced by macro (#213)
1 parent e7039aa commit 29e0379

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

Sources/CasePathsMacros/CasePathableMacro.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ extension CasePathableMacro: MemberMacro {
103103

104104
var decls: [DeclSyntax] = [
105105
"""
106-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
106+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
107107
public subscript(root: \(enumName)) -> CasePaths.PartialCaseKeyPath<\(enumName)> {
108108
\(raw: rootSubscriptCases.map { "\($0.description)\n" }.joined())\(raw: subscriptReturn)
109109
}
110110
\(raw: casePaths.map(\.description).joined(separator: "\n"))
111-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<\(enumName)>]> {
111+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<\(enumName)>]> {
112112
\(raw: allCases.isEmpty ? "let" : "var") allCasePaths: \
113113
[CasePaths.PartialCaseKeyPath<\(enumName)>] = []\
114114
\(raw: allCases.map { "\n\($0.description)" }.joined())

Tests/CasePathsMacrosTests/CasePathableMacroTests.swift

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
case fizz(buzz: String)
3333
case fizzier(Int, buzzier: String)
3434
35-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
35+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
3636
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
3737
if root.is(\.bar) {
3838
return \.bar
@@ -82,7 +82,7 @@
8282
return (v0, v1)
8383
}
8484
}
85-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
85+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
8686
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
8787
allCasePaths.append(\.bar)
8888
allCasePaths.append(\.baz)
@@ -109,12 +109,12 @@
109109
#"""
110110
enum EnumWithNoCases {
111111
112-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
112+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
113113
public subscript(root: EnumWithNoCases) -> CasePaths.PartialCaseKeyPath<EnumWithNoCases> {
114114
\.never
115115
}
116116
117-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<EnumWithNoCases>]> {
117+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<EnumWithNoCases>]> {
118118
let allCasePaths: [CasePaths.PartialCaseKeyPath<EnumWithNoCases>] = []
119119
return allCasePaths.makeIterator()
120120
}
@@ -140,7 +140,7 @@
140140
enum Foo {
141141
case bar(Never)
142142
143-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
143+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
144144
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
145145
if root.is(\.bar) {
146146
return \.bar
@@ -155,7 +155,7 @@
155155
return v0
156156
}
157157
}
158-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
158+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
159159
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
160160
allCasePaths.append(\.bar)
161161
return allCasePaths.makeIterator()
@@ -182,7 +182,7 @@
182182
public enum Foo {
183183
case bar(Int), baz(String)
184184
185-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
185+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
186186
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
187187
if root.is(\.bar) {
188188
return \.bar
@@ -208,7 +208,7 @@
208208
return v0
209209
}
210210
}
211-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
211+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
212212
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
213213
allCasePaths.append(\.bar)
214214
allCasePaths.append(\.baz)
@@ -236,7 +236,7 @@
236236
public enum Foo {
237237
case bar(Int)
238238
239-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
239+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
240240
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
241241
if root.is(\.bar) {
242242
return \.bar
@@ -251,7 +251,7 @@
251251
return v0
252252
}
253253
}
254-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
254+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
255255
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
256256
allCasePaths.append(\.bar)
257257
return allCasePaths.makeIterator()
@@ -275,7 +275,7 @@
275275
package enum Foo {
276276
case bar(Int)
277277
278-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
278+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
279279
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
280280
if root.is(\.bar) {
281281
return \.bar
@@ -290,7 +290,7 @@
290290
return v0
291291
}
292292
}
293-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
293+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
294294
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
295295
allCasePaths.append(\.bar)
296296
return allCasePaths.makeIterator()
@@ -314,7 +314,7 @@
314314
private enum Foo {
315315
case bar(Int)
316316
317-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
317+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
318318
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
319319
if root.is(\.bar) {
320320
return \.bar
@@ -329,7 +329,7 @@
329329
return v0
330330
}
331331
}
332-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
332+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
333333
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
334334
allCasePaths.append(\.bar)
335335
return allCasePaths.makeIterator()
@@ -390,12 +390,12 @@
390390
#"""
391391
enum Foo: CasePathable {
392392
393-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
393+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
394394
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
395395
\.never
396396
}
397397
398-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
398+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
399399
let allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
400400
return allCasePaths.makeIterator()
401401
}
@@ -416,12 +416,12 @@
416416
#"""
417417
enum Foo: CasePaths.CasePathable {
418418
419-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
419+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
420420
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
421421
\.never
422422
}
423423
424-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
424+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
425425
let allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
426426
return allCasePaths.makeIterator()
427427
}
@@ -447,7 +447,7 @@
447447
enum Foo {
448448
case bar(_ int: Int, _ bool: Bool)
449449
450-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
450+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
451451
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
452452
if root.is(\.bar) {
453453
return \.bar
@@ -462,7 +462,7 @@
462462
return (v0, v1)
463463
}
464464
}
465-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
465+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
466466
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
467467
allCasePaths.append(\.bar)
468468
return allCasePaths.makeIterator()
@@ -489,7 +489,7 @@
489489
enum Foo {
490490
case bar(Bar<Self>)
491491
492-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
492+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
493493
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
494494
if root.is(\.bar) {
495495
return \.bar
@@ -504,7 +504,7 @@
504504
return v0
505505
}
506506
}
507-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
507+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
508508
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
509509
allCasePaths.append(\.bar)
510510
return allCasePaths.makeIterator()
@@ -531,7 +531,7 @@
531531
enum Foo {
532532
case bar(int: Int = 42, bool: Bool = true)
533533
534-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
534+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
535535
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
536536
if root.is(\.bar) {
537537
return \.bar
@@ -546,7 +546,7 @@
546546
return (v0, v1)
547547
}
548548
}
549-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
549+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
550550
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
551551
allCasePaths.append(\.bar)
552552
return allCasePaths.makeIterator()
@@ -607,7 +607,7 @@
607607
#endif
608608
#endif
609609
610-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
610+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
611611
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
612612
if root.is(\.bar) {
613613
return \.bar
@@ -725,7 +725,7 @@
725725
}
726726
#endif
727727
#endif
728-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
728+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
729729
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
730730
allCasePaths.append(\.bar)
731731
#if os(macOS)
@@ -770,7 +770,7 @@
770770
enum Foo {
771771
case bar
772772
773-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
773+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
774774
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
775775
if root.is(\.bar) {
776776
return \.bar
@@ -787,7 +787,7 @@
787787
return ()
788788
}
789789
}
790-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
790+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
791791
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
792792
allCasePaths.append(\.bar)
793793
return allCasePaths.makeIterator()
@@ -843,7 +843,7 @@
843843
*/
844844
case fizz, buzz
845845
846-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
846+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
847847
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
848848
if root.is(\.bar) {
849849
return \.bar
@@ -913,7 +913,7 @@
913913
return ()
914914
}
915915
}
916-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
916+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
917917
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
918918
allCasePaths.append(\.bar)
919919
allCasePaths.append(\.baz)
@@ -948,7 +948,7 @@
948948
// case foo
949949
case bar
950950
951-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
951+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
952952
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
953953
if root.is(\.bar) {
954954
return \.bar
@@ -967,7 +967,7 @@
967967
return ()
968968
}
969969
}
970-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
970+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
971971
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
972972
allCasePaths.append(\.bar)
973973
return allCasePaths.makeIterator()
@@ -1004,7 +1004,7 @@
10041004
case fizzier/*Comment in case*/(Int, buzzier: String)
10051005
case fizziest // Comment without associated value
10061006
1007-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
1007+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
10081008
public subscript(root: Foo) -> CasePaths.PartialCaseKeyPath<Foo> {
10091009
if root.is(\.bar) {
10101010
return \.bar
@@ -1068,7 +1068,7 @@
10681068
return ()
10691069
}
10701070
}
1071-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
1071+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Foo>]> {
10721072
var allCasePaths: [CasePaths.PartialCaseKeyPath<Foo>] = []
10731073
allCasePaths.append(\.bar)
10741074
allCasePaths.append(\.baz)
@@ -1099,7 +1099,7 @@
10991099
enum Action<Element> {
11001100
case element(Element)
11011101
1102-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
1102+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
11031103
public subscript(root: Action) -> CasePaths.PartialCaseKeyPath<Action> {
11041104
if root.is(\.element) {
11051105
return \.element
@@ -1114,7 +1114,7 @@
11141114
return v0
11151115
}
11161116
}
1117-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Action>]> {
1117+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Action>]> {
11181118
var allCasePaths: [CasePaths.PartialCaseKeyPath<Action>] = []
11191119
allCasePaths.append(\.element)
11201120
return allCasePaths.makeIterator()
@@ -1146,7 +1146,7 @@
11461146
enum Action {
11471147
case element(Element)
11481148
1149-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
1149+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
11501150
public subscript(root: Action) -> CasePaths.PartialCaseKeyPath<Action> {
11511151
if root.is(\.element) {
11521152
return \.element
@@ -1161,7 +1161,7 @@
11611161
return v0
11621162
}
11631163
}
1164-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Action>]> {
1164+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Action>]> {
11651165
var allCasePaths: [CasePaths.PartialCaseKeyPath<Action>] = []
11661166
allCasePaths.append(\.element)
11671167
return allCasePaths.makeIterator()
@@ -1191,7 +1191,7 @@
11911191
enum Action<Element> {
11921192
case element(Array<Element>)
11931193
1194-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
1194+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
11951195
public subscript(root: Action) -> CasePaths.PartialCaseKeyPath<Action> {
11961196
if root.is(\.element) {
11971197
return \.element
@@ -1206,7 +1206,7 @@
12061206
return v0
12071207
}
12081208
}
1209-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Action>]> {
1209+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Action>]> {
12101210
var allCasePaths: [CasePaths.PartialCaseKeyPath<Action>] = []
12111211
allCasePaths.append(\.element)
12121212
return allCasePaths.makeIterator()
@@ -1239,7 +1239,7 @@
12391239
case secondElement(Element)
12401240
case thirdElement(Element, Element, Int)
12411241
1242-
public struct AllCasePaths: CasePaths.CasePathReflectable, Sendable, Sequence {
1242+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
12431243
public subscript(root: Action) -> CasePaths.PartialCaseKeyPath<Action> {
12441244
if root.is(\.element) {
12451245
return \.element
@@ -1276,7 +1276,7 @@
12761276
return (v0, v1, v2)
12771277
}
12781278
}
1279-
public func makeIterator() -> IndexingIterator<[CasePaths.PartialCaseKeyPath<Action>]> {
1279+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Action>]> {
12801280
var allCasePaths: [CasePaths.PartialCaseKeyPath<Action>] = []
12811281
allCasePaths.append(\.element)
12821282
allCasePaths.append(\.secondElement)

0 commit comments

Comments
 (0)