Bug with simple name lookup inside extends clause?

Alex Buckley alex.buckley at oracle.com
Thu Feb 13 16:02:37 PST 2014


Regression. The scope of class T's declaration is the body of class 
Test, including the 'extends' clause of class Two and the body of class 
Two. However, the type parameter T declared for class Two should shadow 
class T's declaration throughout the 'extends' clause and body of class Two.

Related bug: https://bugs.openjdk.java.net/browse/JDK-7118412.

Alex

On 2/13/2014 3:28 PM, Liam Miller-Cushon wrote:
> The following snippet compiles with javac7, but not javac8-b128.
>
> Shouldn't the type parameter T be shadowing the inner class Test.T?
>
> ===
> class Test {
>    class T<E> {}
>    abstract class One<E> {
>      abstract E foo();
>    }
>    abstract class Two<T> extends One<T> {
>      abstract T foo();
>    }
> }
> ===
>
> error: foo() in Test.Two cannot override foo() in Test.One
>      abstract T foo();
>                 ^
>    return type T is not compatible with Test.T
>    where T,E are type-variables:
>      T extends Object declared in class Test.Two
>      E extends Object declared in class Test.One


More information about the compiler-dev mailing list