bug icon indicating copy to clipboard operation
bug copied to clipboard

Type parameters in projections to generic superclass are not resolved from bytecode

Open scabug opened this issue 14 years ago • 2 comments

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

scabug avatar Oct 18 '11 14:10 scabug

Imported From: https://issues.scala-lang.org/browse/SI-5087?orig=1 Reporter: Moritz Uhlig (muhlig) Affected Versions: 2.8.1, 2.9.1

scabug avatar Oct 18 '11 14:10 scabug

@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.

scabug avatar Oct 31 '11 15:10 scabug