Skip to content

invalid generic signature for type params bounded by primitive #9846

Open
@scabug

Description

@scabug

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendbytecodeerasurefixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions