Can we skip emitting unnecessary mixin methods in the new trait encoding scheme?
With revision retronym/scala@8ee7aca I compiled the following example:
trait T { final def m = 1 }
class C extends T
class D extends T
class A {
def foo(t: T) = t.m
}
- Both classes
C and D get an override def m = super[T].m. Are the necessary?
- Could the default method in
T be marked final?
- Could we skip the mixin methods in
C and D if T.m was not final?
In the current situation, the invocation t.m in class A is polymorphic: the bytecode is INVOKEINTERFACE T.m ()I, which resolves to either C.m or D.m.