Structural types and inline defs

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?

There is at least the issue that sometimes inline methods become regular ones:

trait A:
  def foo: Int

class B extends A:
  inline def foo: Int = 4


val x: A = new B

x.foo // cannot be inlined, called as a regular method

I don’t know exactly how other inline features behave in that case to be honest

I do agree however that this would be nice to have, but maybe it’s just better to use type classes, even in this case