File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Sources/SwiftSyntaxMacroExpansion
Tests/SwiftSyntaxMacroExpansionTest Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -530,7 +530,11 @@ public class AttributeRemover: SyntaxRewriter {
530530
531531 public override func visit( _ node: AttributeListSyntax ) -> AttributeListSyntax {
532532 var filteredAttributes : [ AttributeListSyntax . Element ] = [ ]
533- for case . attribute( let attribute) in node {
533+ for attribute in node {
534+ guard case . attribute( let attribute) = attribute else {
535+ filteredAttributes. append ( attribute)
536+ continue
537+ }
534538 if self . predicate ( attribute) {
535539 var leadingTrivia = attribute. leadingTrivia
536540
Original file line number Diff line number Diff line change @@ -470,4 +470,21 @@ final class AttributeRemoverTests: XCTestCase {
470470 """
471471 )
472472 }
473+
474+ func testKeepPoundIfInAttributes( ) {
475+ assertSyntaxRemovingTestAttributes (
476+ """
477+ #if true
478+ @inlinable
479+ #endif
480+ func f() {}
481+ """ ,
482+ reduction: """
483+ #if true
484+ @inlinable
485+ #endif
486+ func f() {}
487+ """
488+ )
489+ }
473490}
You can’t perform that action at this time.
0 commit comments