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

Vicente Romero vromero at openjdk.java.net
Mon May 23 21:12:23 UTC 2022


On Mon, 23 May 2022 09:20:51 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> But, to be clear, we should first make sure that this is the feature we want. IMHO it is not: `Box<? extends Atom>` is a wildcard type that contains only one witness: `Atom`. So, subtyping-wise, I don't think it is ok to conclude that `Box<Atom.ref>` <: `Box<? extends Atom>`, because `Atom.ref` is not in the "span" of the wildcard type on the RHS of the subtyping check.
>
> And, this is made messier by the fact that:
> 
> 
> val = ref
> 
> 
> In my example does not trigger a subtying test. It triggers an assignment conversion, which in turn can use the new form of parameterized conversions.

> This extra check feels outside the spirit of the rules discussed in https://openjdk.java.net/jeps/8261529. That is, I'd expect type containment to recurse using `isBoundedBy` instead of `isSubtype` (as the first branch of this code does).

just to provide some context, the reason that supported in my view using this extra check comes from the universal tvars jep in particular where it says:


Changing a wildcard bound in a parameterized type from a universal type-variable type (T) or a primitive class type (Point) to its reference type (T.ref, Point.ref), or vice versa (where the conversion is not already allowed by subtyping):

this is why on a failure of isBoundedBy which at the end is based on subtyping I tried this more general relation. Although I realize from the additional points you mentioned here that these opens questions in other fronts like type well-formedness.

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

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



More information about the valhalla-dev mailing list