File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Tests/CasePathsMacrosTests Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,11 @@ extension EnumCaseElementListSyntax.Element {
257
257
for index in associatedValue. parameters. indices {
258
258
associatedValue. parameters [ index] . type. trailingTrivia = " "
259
259
associatedValue. parameters [ index] . defaultValue = nil
260
+ if associatedValue. parameters [ index] . firstName? . tokenKind == . wildcard {
261
+ associatedValue. parameters [ index] . colon = nil
262
+ associatedValue. parameters [ index] . firstName = nil
263
+ associatedValue. parameters [ index] . secondName = nil
264
+ }
260
265
}
261
266
return " ( \( associatedValue. parameters. trimmed) ) "
262
267
}
Original file line number Diff line number Diff line change @@ -299,6 +299,40 @@ final class CasePathableMacroTests: XCTestCase {
299
299
"""
300
300
}
301
301
}
302
+
303
+ func testWildcard( ) {
304
+ assertMacro {
305
+ """
306
+ @CasePathable enum Foo {
307
+ case bar(_ int: Int, _ bool: Bool)
308
+ }
309
+ """
310
+ } expansion: {
311
+ """
312
+ enum Foo {
313
+ case bar(_ int: Int, _ bool: Bool)
314
+
315
+ struct AllCasePaths {
316
+ var bar: CasePaths.AnyCasePath<Foo, (Int, Bool)> {
317
+ CasePaths.AnyCasePath<Foo, (Int, Bool)>(
318
+ embed: Foo.bar,
319
+ extract: {
320
+ guard case let .bar(v0, v1) = $0 else {
321
+ return nil
322
+ }
323
+ return (v0, v1)
324
+ }
325
+ )
326
+ }
327
+ }
328
+ static var allCasePaths: AllCasePaths { AllCasePaths() }
329
+ }
330
+
331
+ extension Foo: CasePaths.CasePathable {
332
+ }
333
+ """
334
+ }
335
+ }
302
336
303
337
func testSelf( ) {
304
338
assertMacro {
You can’t perform that action at this time.
0 commit comments