Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
panacekcz opened this issue Dec 7, 2018 · 0 comments

Comments

@panacekcz
Copy link
Contributor

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)
odersky added a commit to dotty-staging/dotty that referenced this issue Dec 16, 2018
`matches` incorrectly returned a match if two members
differed only in their type parameters.
@smarter smarter closed this as completed in 668a637 Jan 6, 2019
smarter added a commit that referenced this issue Jan 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant