You need to parse the bytecode:
trait A { val x: Int = 3 } public abstract class A$class extends java.lang.Object{ public static void $init$(A); Code: 0: aload_0 1: iconst_3 2: invokeinterface #12, 2;
See line 1 - the only place that matters is in the bytecode for the init method!
You cannot do this because if you have
trait A { val x: Int = 3 } trait B extends A { override val x = 7 } class C extends B {}
You will find that C extends A$_setter_$x_$eq does nothing - make a call to A$class.$init$ no-op and make it invalid.
Evidence:
public class C extends java.lang.Object implements B,scala.ScalaObject{ public void A$_setter_$x_$eq(int); Code: 0: return public void B$_setter_$x_$eq(int); Code: 0: aload_0 1: iload_1 2: putfield
source share