How does the Scala compiler handle concrete trait methods?

前端 未结 2 2016
隐瞒了意图╮
隐瞒了意图╮ 2021-02-20 16:07

If I have the following Scala class:

abstract class MyOrdered extends Ordered[MyOrdered] {
    def id: Int
    def compare(that : MyOrdered) : Int =
        if (         


        
2条回答
  •  旧时难觅i
    2021-02-20 16:27

    Note: that latest commit for Scal 2.12.x (August 2016) might optimize things a bit in compiler/scala/tools/nsc/backend/jvm:

    SD-192 Change scheme for trait super accessors

    Rather than putting the code of a trait method body into a static method, leave it in the default method.
    The static method (needed as the target of the super calls) now uses invokespecial to exactly call that method.

提交回复
热议问题