Skip to content

inliner picks the wrong default method #140

Closed
@lrytz

Description

@lrytz
trait T {
  @inline def f = 0
}

trait U extends T {
  @inline override def f = 1
}

trait V extends T {
  def m = 0
}

final class A extends V with U {
  override def m = super[V].m
}

object Test {
  def main(args: Array[String]): Unit = {
    println((new A).f)
  }
}
$ qsc Test.scala && qs Test && qsc -Yopt:l:classpath Test.scala && qs Test
1
0

See https://github.com/scala/scala/blob/93f209dd65d5c05fc2cb61916a850940499c9261/src/compiler/scala/tools/nsc/backend/jvm/opt/ByteCodeRepository.scala#L131-L167 - just picks the first match it finds in parents.

We need to implement "maximally-specific superinterface method" (https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-5.html#jvms-5.4.3.3).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions