RFR: addressing several issues in the implementation of universal tvars [v9]

Vicente Romero vromero at openjdk.java.net
Fri Jun 10 15:15:30 UTC 2022


On Fri, 10 Jun 2022 10:34:57 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> it could probably be better to write the test as:
>> 
>> field = t;
>> action.accept(field = t);
>> 
>> what do you think?
>
> Ah I see. So there's two things here:
> 1. assignment from `t` to `field` - that works ok (with warning)
> 2. passing `field` (of type `T.ref`) to `action`.
> 
> On (2), `action` is subject to capture conversion, so its type is `Consumer<#CAP>` where `T <: #CAP `. So, we have to check whether `T.ref` is assignable to `#CAP`. I believe this currently fails because `T.ref` cannot be "lifted" to `#CAP`.
> 
> I think this is ok for now, but I note that, when type variables are involved, there are always two ways to prove subtyping:
> 
> * T <: S iff upper(T) <: S
> * S <: T iff S <: lower(T)
> 
> It is true that, in (2) you cannot "lift" `T.ref` to `'#CAP`, but it is also true that you can "unlift" `#CAP` down to `T`, at which point you would have a structural comparison between `T.ref` and `T` again (which would be ok).
> 
> Whether or not this is what we want to do is a specification question - we can revisit later. (Here I note that we don't currently do this even for ordinary unchecked conversions, so what we have is probably ok).

I see, thanks for the review

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

PR: https://git.openjdk.org/valhalla/pull/684



More information about the valhalla-dev mailing list