magnolia
magnolia copied to clipboard
Consider not using Mirrors for derivation, so that multi-level hierarchies can be suppored
Mirrors give us a lot "for free", but I think we could do just as well without them (that is, give the same user experience & performance), while additionally supporting multi-level hierarchies
I agree. I've been thinking about rewriting most of the derivation logic to macros for a while.
But when it comes to ditching Mirrors altogether, there is IMHO a problem with accessing subtypes of a trait. (And that is mostly why I haven't mentioned it before) But there is also a chance that I missed something.
There is also this docs page. It still uses Mirrors, but on a bit lower level. Maybe it would work better?
But when it comes to ditching Mirrors altogether, there is IMHO a problem with accessing subtypes of a trait. (And that is mostly why I haven't mentioned it before) But there is also a chance that I missed something.
Of a non-sealed trait? I suppose for sealed traits / enums we can use Symbol.children?
If not, maybe indeed summoning mirrors and using this information level by level would work.
Ok, so that is the case. I just missed it... repeatedly... :facepalm:
So I think that it should be more or less straightforward then.
Btw hopefully Mirrors should support it soon: https://github.com/lampepfl/dotty/pull/11686