I imagine this question has been brought up before but I couldn’t find it, it’s basically similar to kotlin’s “reified” types using inline.
When I have
extension [T, U](inline wrapper: {
def init(u: U): Unit
def wrap(t: T): U
} def initAndWrap(t: T): U = {
val res = wrapper.wrap(t)
wrapper.init(res)
res
}
the compiler rightfully declares that I need to import Selectable for reflection (or provide my own), nevertheless when actually expanding this inline, there should be no case of reflection (at least not needed).
I am sure I can implement a macro based selectable based on inline that is able to do this expansion but this feels like something the compiler should be doing.
I happen to have structurally similar types that share this structure without a common type, that’s why I would have to resort to this but I think the principle in general applies similar to compiletime.erasedValue or constTuple, etc.
Would something like this be possible or would it cause unexpected issues?