« Return to Thread: [scala] Question on overriding virtual types

[scala] Question on overriding virtual types

by nikov :: Rate this Message:

Reply to Author | View in Thread

Hi,

I need help to gain some intuition behind virtual types. Consider this code:

///////////////////////////////////////////////////
trait A {
  type T
  def f(x : T) : T
}

trait B extends A {
  trait T { }
  override def f(x : T) : T = x
}

object C extends B {
  override trait T {
    def g {  }
  }
  override def f(x : T) : T = { x.g; x }
}

///////////////////////////////////////////////////

Which members are overridden by the members T and f in the object C?
Are those T and f in trait B?
How is it possible to override trait T in B with completely unrelated
trait T in C?


Thanks,
Vladimir

 « Return to Thread: [scala] Question on overriding virtual types