Visibility Issue with ExtensionMacro in Different Files When Attached to Protocol #74644
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
swift macro
Feature → declarations: Swift `macro` declarations
Description
It appears that extension methods generated by ExtensionMacro attached to protocols are not visible across different files. This issue persists even though it was previously reported and marked as closed.
Reproduction
Expected behavior
"Test".printFoo() // <-- Should compile and print "foo" based on the extension method synthesized by the ExtensionMacro
Environment
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Xcode: Version 15.4 (15F31d)
Target: arm64-apple-macosx14.0
Additional information
It was noted in the previous issue (reference: #69073) that the visibility problem occurs only in different files. When all the related code is in the same file, the generated extension methods are visible and work as expected.
However, the method is not visible if the call to printFoo() is made in a different file.
This behavior suggests that the ExtensionMacro added members might be scoped as
fileprivate
even when generated with aninternal
or evenpublic
modifier.The text was updated successfully, but these errors were encountered: