1

While understanding this answer I wrote my own example which uses a trait with scala-library version 2.11.4:

trait Trace {
  def id(): Int
  def concrete(i : Int) = println(i)
}

from a program uses version 2.12.0-M5.

object App {
  def main(args: Array[String]) = {
    println("st")
    val t = new TraceImpl
    println(t.id())
    t.concrete(10)
  }

  class TraceImpl extends Trace{
    override def id(): Int = 1
  }
}

I expected that some exception would be thrown at runtime, but the program works fine and prints:

st
1
10

Why? Runtime implementation of traits is supposed to be changed as of version 2.12.x?

Community
  • 1
  • 1
user3663882
  • 6,957
  • 10
  • 51
  • 92

0 Answers0