Clarifications on SoV documents

Remi Forax forax at univ-mlv.fr
Thu Apr 23 20:23:40 UTC 2020


> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Jeudi 23 Avril 2020 22:11:17
> Objet: Clarifications on SoV documents

> Srikanth asked me to make a few clarifications on the SoV documents. I'll
> summarize them here and then later work them into the docs.

> 1. Array subtyping. Historically, array covariance worked like this:

> if T <: U, then T[] <: U[]

> In Valhalla, this is refined to be:

> if T.ref <: U, then T[] <: U[]

> Because T.ref == T for reference types, this rule generalizes the previous rule.

> There is no inline widening/narrowing conversion between array types; array
> types are reference types.

> Example:

> V[] va = ...
> V.ref[] vb = ...
> vb = va // allowed by ordinary subtyping
> va = vb // not allowed
> va = (V[]) vb // allowed, may CCE

> 2. Bounds checking. If we have a bound:

> class Foo<T extends U> { }

> then this was historically satisfied if T <: U. In Valhalla, this is amended in
> the same way as (1):

> X is within bound `T extends U` if X.ref <: U

> If `U` is an inline type, the bounds `T extends U` does not make sense, so is
> rejected.

> 3. This story isn't written yet, but where we're aiming (everyone but Srikanth,
> please hold questions on "how would that work" until I write this up) is that
> inline types can be used as type parameters for erased generics _without_
> having to say `Foo<V.ref>`. This represents a shift from where we were before,
> where we didn't allow inlines as type arguments.
No, we know, you want to use Foo[V] for reified generics (so we can make reified generics covariant). 

Rémi 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20200423/b66d926c/attachment-0001.htm>


More information about the amber-spec-experts mailing list