RFR: universal type variables: initial prototype [v3]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Wed Aug 11 15:01:53 UTC 2021


On Wed, 11 Aug 2021 05:10:28 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 3616:
>> 
>>> 3614:                         !t.isValueProjection() &&
>>> 3615:                         from.head.hasTag(TYPEVAR) &&
>>> 3616:                         ((TypeVar)from.head).projection != null &&
>> 
>> Shouldn't this test be `isUniversal()` ?
>
> doing this change right now breaks the build, I think it is because we generate reference projections for universal type vars in a lazy way, so some universal type variables could have its projection field set to null

ugh - I understand - moving forward it'd be nice not to depend on tricky init semantics.

>> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 2663:
>> 
>>> 2661:                         && ((JCFieldAccess)tree.meth).selected.hasTag(IDENT)
>>> 2662:                         && TreeInfo.name(((JCFieldAccess)tree.meth).selected) == names._super;
>>> 2663:                 boolean qualifierIsUniversal = allowUniversalTVars && qualifier.hasTag(TYPEVAR) && ((TypeVar)qualifier).isValueProjection();
>> 
>> This should be `isUniversal()` I think - `wait` and friends should warn, even on `.ref` stuff.
>
> not sure to be honest, although there is no reference in the JEP to these warnings so we can do either now

I double checked with Brian yesterday - he confirmed that both `T` and `T.ref` should not support identity operation (well, given warning when attempting to).

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

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



More information about the valhalla-dev mailing list