magnolia icon indicating copy to clipboard operation
magnolia copied to clipboard

Consider not using Mirrors for derivation, so that multi-level hierarchies can be suppored

Open adamw opened this issue 4 years ago • 4 comments

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

adamw avatar Jun 10 '21 12:06 adamw

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?

KacperFKorban avatar Jun 10 '21 13:06 KacperFKorban

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.

adamw avatar Jun 10 '21 13:06 adamw

Ok, so that is the case. I just missed it... repeatedly... :facepalm:

So I think that it should be more or less straightforward then.

KacperFKorban avatar Jun 10 '21 13:06 KacperFKorban

Btw hopefully Mirrors should support it soon: https://github.com/lampepfl/dotty/pull/11686

ghostdogpr avatar Jun 21 '21 00:06 ghostdogpr