In Scala 2.12, bodies of methods defined in traits will be compiled to default methods in the interface classfile. In short, we have the following bytecode formats for concrete trait methods:
- 2.11.x: trait method bodies are in static methods in the trait's
T$impl
class. Classes extending a trait get a virtual method that implements the abstract method in the interface and forwards to the static implementation method. - 2.12.0-M4: trait method bodies are in (non-static) interface default methods, subclasses get an virtual method (overridding the default method) that forwards to that default method using