unnecessary class

View: New views
1 Messages — Rating Filter:   Alert me  

unnecessary class

by Andrew Gaydenko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Say, I have:

trait T {
  def f : List[Int]
}

trait R extends T {
  abstract override def f = super.f ::: List(1)
}

class TheT extends T {
  def f : List[Int] = List(0)
}

object test {
  def main(args : Array[String]) : Unit = {
    val t = new TheT with R
    println(t.f) // List(0, 1)
  }
}

How to to avoid TheT class declaration at all (having TheT's 'f' body in
hand)?