- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
traits, generics, java interop + @specialized
Wed, 2010-05-26, 18:10
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 extends T2 {
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 extends ScalaObject
{
public abstract A m(A paramA);
public abstract A specified(A paramA);
}
public abstract class T2
implements Test, ScalaObject
{
public Object specified(Object a)
{
return Test.class.specified(this, a); }
public T2() { Test.class.$init$(this); }
}
public class JTest extends T2
{
public A m(A a)
{
return a;
}
}
> scalac -version
Scala compiler version 2.8.0.r22036-b20100526020129 -- Copyright
2002-2010, LAMP/EPFL
Mixed in methods seem to lack their Java signature. I updated the ticket, thanks for reporting!
iulian
On Wed, May 26, 2010 at 7:03 PM, Vladimir Kirichenko <vladimir.kirichenko@gmail.com> wrote:
--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais