Skip to content

Static forwarders are sometimes missing generic signatures #11305

Open
@lrytz

Description

@lrytz

There's a regression from 2.12.7 to 2.12.8, but also some older inconsistency.

Source file:

trait A[T] {
  type U
  def foo(t: T): List[String] = Nil
  def bar(u: U): List[String] = Nil
}
object O extends A[String] { type U = String }

2.12.7

When compiled with 2.12.7, we get signatures for the default methods in A.class:

  // signature (TT;)Lscala/collection/immutable/List<Ljava/lang/String;>;
  public default foo(Ljava/lang/Object;)Lscala/collection/immutable/List;

  // access flags 0x1
  // signature (Ljava/lang/Object;)Lscala/collection/immutable/List<Ljava/lang/String;>;
  public default bar(Ljava/lang/Object;)Lscala/collection/immutable/List;

The signature of foo refers to A's type parameter T. in the signature of bar, the type member U is erased to Object.

Looking at the mixin methods in the module class O$, we see that O$.bar has a signature (the same as A.bar), but O$.foo doesn't have any. Not sure if that's by design, or if that's a bug. Simply using the same signature as A.foo would be wrong, as the O$ class doesn't have a type parameter T.

Looking at the static forwarders in O, O.bar has a signature, O.foo doesn't.

Abstract Class

If we change A to be an abstract class, the signatures for A.foo and A.bar are the same as before. O$ no longer has mixins. The static forwarders in O are both without signature. I assume that's a bug? O.bar could have the same signature as A.bar.

2.12.8

When compiling the original source (trait A) with 2.12.8, there's a difference: the static forwarder O.bar is now also without signature. This is the regression compared to 2.12.7.

Other than that, 2.12.8 produces the same methods/signatures as 2.12.7 (also if A is an abstract class).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions