RFR: universal type variables: initial prototype

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Aug 5 13:12:46 UTC 2021


On Wed, 4 Aug 2021 15:29:35 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java line 1946:
>> 
>>> 1944:         public Type lower;
>>> 1945: 
>>> 1946:         public boolean universal = false;
>> 
>> Can we use a flag on the tsym for this? After all, being "universal" is a declaration (symbol) not a use (type) property?
>
> well yes and no, if we have:
> 
> class C<__universal T> {
>     T.ref t;
> }
> 
> T and T.ref share the same symbol but they have different types that's why the universal field has been set to the type

yes, but `universal` is a property of the declaration, while `ref-ness` is a property of the use-site (hence type). Note that the underlying Valhalla compiler already has machinery to talk about reference projections, so perhaps we should use that to speak about `T` vs. `T.ref`, rather than inventing a new one. But we still need a flag somewhere to say whether the variable was declared as universal or not (as that affects what's compatible with that var).

-------------

PR: https://git.openjdk.java.net/valhalla/pull/521


More information about the valhalla-dev mailing list