Type-variable references from local interface declaration

Remi Forax forax at univ-mlv.fr
Mon Jun 15 11:55:42 UTC 2020


It's not a spec bug,
it's an implementation bug, the interface defines a new static context so the type-variable U should not be available.

Rémi 

----- Mail original -----
> De: "Tagir Valeev" <amaembo at gmail.com>
> À: "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Lundi 15 Juin 2020 13:38:24
> Objet: Type-variable references from local interface declaration

> Hello!
> 
> The spec draft for local interfaces and enums [1] tells that it's
> illegal to refer to the enclosing method type parameter from the local
> interface. Here's a simplified sample from the spec:
> 
> class Box<T> {
>    static <U> Box<U> make(U val) {
>        interface Checker {
>            void check(U val); // compile-time error
>        }
>        return null;
>    }
> }
> 
> However, it's successfully compilable using javac 15-ea+26-1287. I
> believe, either spec or implementation should be adjusted.
> 
> With best regards,
> Tagir Valeev.
> 
> [1]
> http://cr.openjdk.java.net/~gbierman/jep384/jep384-20200506/specs/local-statics-jls.html#jls-6.5.5.1


More information about the amber-dev mailing list