Scala overridden fields: are overridden fields also in virtual table?
I'm new to Scala. Conceptually, overridden class methods are in vritual table, but I'm not sure whether overridden fields are also in virtual table?
class A
{
private var str: String = "A"
val x: A = this
override def toString(): String = str
def m1(other: AnyRef): AnyRef = {
println("This is A.m1(AnyRef)")
other
}
}
class B extends A {
private var str: String = "B"
var z: Int = 0
override val x: B = this
override def m1(other: AnyRef): B = {
println("This is B.m1(AnyRef)")
this
}
}
For the code snippet above, my understanding is that method m1
is in class A
and B
's virtual
table respectively, but I'm not sure whether field x
is in virtual table too.