swiftlang / swiftlang/swift-syntax

MemberAttributeMacro do not visit members that are guarded with IfConfigDecl

Open
#3,106 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
3.7k
Forks
553
Avg merge
5d 13h
Merged PRs (30d)
16

Description

### Description

The `MemberAttributeMacro` does not get invoked for members that are inside `#if` guards.

### Steps to Reproduce

Looking at the unit tests, I can add a new one to the MemberAttributeMacroTests:
```
func testAttributeWithIfConfigDecl() {
assertMacroExpansion(
"""
@wrapAllProperties struct S {
#if true
var value = 1
#endif
}
""",
expandedSource: """
struct S {
#if true
@Wrapper
var value = 1
#endif
}
""",
macros: ["wrapAllProperties": WrapAllProperties.self],
indentationWidth: indentationWidth
)
}
```

Actual results is the macro never gets visited for `value` at all.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.