RFR: universal type variables: initial prototype

Vicente Romero vromero at openjdk.java.net
Fri Aug 6 13:28:45 UTC 2021

On Fri, 6 Aug 2021 10:39:15 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> it wont be that simple, see that the method invoked, `Attr.attribTypes`, is doing:
>>     List<Type> types = attribAnyTypes(trees, env);
>>     return chk.checkRefTypes(trees, types, valueOK);
>> and Check.checkRefTypes is doing:
>>         List<JCExpression> tl = trees;
>>         for (List<Type> l = types; l.nonEmpty(); l = l.tail) {
>>             l.head = checkRefType(tl.head.pos(), l.head, valueOK.test(tl.head));
>>             tl = tl.tail;
>>         }
>>         return types;
>> and `Check.checkRefType` is the one using the flag, so in order to do all this at the level of `Attr.visitTypeApply` I will have to gather all the code, popping up code that belongs in `Check`, and then the code in `Attr.visitTypeApply` will lose readability. This is why I opted for the current solution.
> I see what you mean - it seems like the current code is working against us here. In fact, attribAnyTypes specifically says that clients are expected to check for reference types after the fact...
> Here's an idea... you could maybe call attribAnyTypes yourself, to attribute all the types, and then, in the loop you already have, only call checkRefTypes on the types you really need? (e.g. avoid attribTypes)



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

More information about the valhalla-dev mailing list