Skip to content

No Java Signature for mixed-in generic methods #3486

Closed
@scabug

Description

@scabug

Here the thing I've found during exploration of Java complaining on generics in methods generated for specialization.
The problem also found with method generaited for trait implementation.

An example:

Scala:

trait Test[A] {
	def m( a: A ): A
	def specified(a:A):A = a
}

abstract class T2[A] extends Test[A]

Java:

public class JTest<A> extends T2<A> {
	public A m( A a ) {
		return a;
	}
}

java compiler (-Xlint:unckecked) complains about:

specified(java.lang.Object) in T2 implements specified(A) in Test; return type requires unchecked conversion
found   : java.lang.Object
required: A

JD Java Decompiler shows that generated method is not generic:

public abstract interface Test<A> extends ScalaObject
{
  public abstract A m(A paramA);

  public abstract A specified(A paramA);
}


public abstract class T2<A>
  implements Test<A>, ScalaObject
{
  public Object specified(Object a)
  {
    return Test.class.specified(this, a); } 
  public T2() { Test.class.$$init$$(this); }

}

public class JTest<A> extends T2<A>
{
  public A m(A a)
  {
    return a;
  }
}

}
> scalac -version
Scala compiler version 2.8.0.r22036-b20100526020129 -- Copyright 2002-2010, LAMP/EPFL

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions