Skip to content

Implementing a method with wrong number of type parameters leads to runtime AbstractMethodError #5578

Closed
@panacekcz

Description

@panacekcz

This code compiles, but fails at runtime, as long as the numbers of type parameters of the two a methods differ.

trait P[A]{
  def a[T]: A
}
class C extends P[Int]{
  def a = 1
}
object O{
  def main(args: Array[String]) = {
    val p: P[Int] = new C
    println(p.a)
  }
}

Output:

Exception in thread "main" java.lang.AbstractMethodError: C.a()Ljava/lang/Object;
	at O$.main(AME.scala:10)
	at O.main(AME.scala)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions