diff --git a/Sources/CasePathsMacros/CasePathableMacro.swift b/Sources/CasePathsMacros/CasePathableMacro.swift index cf2e483a..aa511f69 100644 --- a/Sources/CasePathsMacros/CasePathableMacro.swift +++ b/Sources/CasePathsMacros/CasePathableMacro.swift @@ -257,6 +257,11 @@ extension EnumCaseElementListSyntax.Element { for index in associatedValue.parameters.indices { associatedValue.parameters[index].type.trailingTrivia = "" associatedValue.parameters[index].defaultValue = nil + if associatedValue.parameters[index].firstName?.tokenKind == .wildcard { + associatedValue.parameters[index].colon = nil + associatedValue.parameters[index].firstName = nil + associatedValue.parameters[index].secondName = nil + } } return "(\(associatedValue.parameters.trimmed))" } diff --git a/Tests/CasePathsMacrosTests/CasePathableMacroTests.swift b/Tests/CasePathsMacrosTests/CasePathableMacroTests.swift index 2ee60aa9..5d2a4938 100644 --- a/Tests/CasePathsMacrosTests/CasePathableMacroTests.swift +++ b/Tests/CasePathsMacrosTests/CasePathableMacroTests.swift @@ -299,6 +299,40 @@ final class CasePathableMacroTests: XCTestCase { """ } } + + func testWildcard() { + assertMacro { + """ + @CasePathable enum Foo { + case bar(_ int: Int, _ bool: Bool) + } + """ + } expansion: { + """ + enum Foo { + case bar(_ int: Int, _ bool: Bool) + + struct AllCasePaths { + var bar: CasePaths.AnyCasePath { + CasePaths.AnyCasePath( + embed: Foo.bar, + extract: { + guard case let .bar(v0, v1) = $0 else { + return nil + } + return (v0, v1) + } + ) + } + } + static var allCasePaths: AllCasePaths { AllCasePaths() } + } + + extension Foo: CasePaths.CasePathable { + } + """ + } + } func testSelf() { assertMacro {