[Macro] Circular reference error when adding extensions to a type decorated by a peer macro

Hi!
I've been working on macros recently. Here's a macro that replaces a generic parameter and puts a new specialized version alongside the original type.

The code without extension part compiles, but it produces circular reference error when adding the extension. And if I move the extension to another file, code compiles.

I did some search and only found this: https://github.com/apple/swift-evolution/blob/main/proposals/0389-attached-macros.md#restrictions-on-arbitrary-names , but not sure if they are actually the same situation.

Is it by design or some bug?

Source code of the macro: GitHub - li3zhen1/WithSpecializedGeneric: An experimental peer macro expanding generic struct or class to a specialized type, so as to avoid dynamic dispatch

This might be related to this bug, which has had quite a bit of discussion, though none from the team yet, and it hasn't been triaged.