bug
bug copied to clipboard
Type parameters in projections to generic superclass are not resolved from bytecode
The following example compiles fine when the Java sources are available to the Scala compiler, but fails when compiling Java and Scala code separate:
// Base.java
public abstract class Base<T> {
public abstract class Inner {
}
public abstract void foo(Base<T>.Inner i);
}
```scala
{code:title=Extends.java}
public class Extends<T> extends Base<T> {
@Override
public void foo(Base<T>.Inner i) {
}
}
// bug.scala
class ExtendsBase extends Base[Int] {
override def foo(i: Base[Int]#Inner) = println("works")
}
class ExtendsExtended extends Extends[Int] {
override def foo(i: Base[Int]#Inner) = println("???")
}
The error message is
src/main/scala/scalabug/bug.scala:10: error: name clash between defined and inherited member:
method foo:(i: scalabug.Base[Int]#Inner)Unit and
method foo:(x$1: scalabug.Base[T]#Inner)Unit in class Extends
have same type after erasure: (i: scalabug.Base#Inner)Unit
override def foo(i: Base[Int]#Inner) = println("???")
^
one error found
Imported From: https://issues.scala-lang.org/browse/SI-5087?orig=1 Reporter: Moritz Uhlig (muhlig) Affected Versions: 2.8.1, 2.9.1
@paulp said: Debugging note: scala is not recognizing foo in Extends as overriding foo in Base (allOverriddenSymbols returns Nil, whereas it contains the Base method if foo is modified to take a String parameter.) Obviously related to Base[Int] vs. Base[T] in the prefix.