New unexpected compile behavior in Xcode 16.3

I have a macro that converts expression into a string literal, e.g.:

#toString(variable) -> "variable"
#toString(TypeName) -> "TypeName"
#toString(\TypeName.property) -> "property"

In Xcode 16.3 #toString(TypeName) stopped to work, compilation throws 'Expected member name or initializer call after type name' error. Everything works fine in Xcode 16.2. I tried to compare build settings between 16.2 and 16.3 but haven't noticed differences that may cause this new error.

The following works in both Xcode versions:

#toString(variable) -> "variable"
#toString(\TypeName.property) -> "property"

Seems like Xcode tries to compile code that shouldn't be compiled because of macro expansion.

Does anybody know what new has appeared in 16.3 and, perhaps, how to fix the problem?

Same found in my project, we have

@attached(member, names: arbitrary)
public macro MacroName<each U: ProtocolName>(_ name: repeat (each U).Type) =
#externalMacro(module: "MacroModule", type: "MacroType")

and calling it

@MacroName(ImplementationOfProtocol)
struct Something { ...... }
class ImplementationOfProtocol: ProtocolName {}

Seeing error "Expected member name or initializer call after type name"

Bug report: FB17081839.

I think you might get more traction on this issue oven on Swift Forums, and specifically the Development > Macros topic area there.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

New unexpected compile behavior in Xcode 16.3
 
 
Q