Skip to content
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

invalid generic signature for type params bounded by primitive #9846

Open
scabug opened this issue Jul 6, 2016 · 1 comment
Open

invalid generic signature for type params bounded by primitive #9846

scabug opened this issue Jul 6, 2016 · 1 comment
Labels
backend bytecode erasure fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)
Milestone

Comments

@scabug
Copy link

scabug commented Jul 6, 2016

scala code:

class A {
  def f[T <: Int](x: T): T = x
}

the generic signature looks like this:

  // access flags 0x1
  // signature <T:Ljava/lang/Object;>(TT;)TT;
  // declaration: T f<T>(T)
  public f(I)I

which is invalid, java generics don't abstract over primitives. the following java code compiles:

public class B {
  public static void main(String[] args) {
    A a = new A();
    System.out.println(a.f(10));
  }
}

but fails to run

Exception in thread "main" java.lang.NoSuchMethodError: A.f(Ljava/lang/Object;)Ljava/lang/Object;
        at B.main(B.java:4)
@scabug
Copy link
Author

scabug commented Jul 6, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9846?orig=1
Reporter: @lrytz
Affected Versions: 2.12.0-M5

@scabug scabug added the quickfix label Apr 7, 2017
@scabug scabug added this to the Backlog milestone Apr 7, 2017
@SethTisue SethTisue added the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend bytecode erasure fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)
Projects
None yet
Development

No branches or pull requests

3 participants