Thank you for the improvement. It looks much better now.
However I found that it became impossible to generate arbitrary conformance now that is required inplace or conformance to some protocol(s) that are not defined by the moment of defining macro.
For example, previously it could be used in some situations, e.g.
Marco definition:
@attached(conformance)
@attached(peer, names: arbitrary)
public macro GenProtocolAndConformance(_: String) = #externalMacro(...)
That could expand the following code:
@GenProtocolAndConformance("MyProtocol")
public struct MyStruct {
var var1: Int
func foo() {
// do stuf
}
// ...
}
To:
public struct MyStruct {
var var1: Int
func foo() {
// do stuf
}
// ...
}
// Expands to
protocol MyProtocol {
var var1: Int
func foo()
}
extension MyStruct : MyProtocol {}
If I understand correctly, now it is impossible. I've tried to do it with both: extension and peer macro. With extension I can't define unknown protocol and with peer macro I have the following error:
error: macro expansion cannot introduce extension
Not sure if it should be addressed here (please let me know if this is a wrong place).