> On Nov 22, 2017, at 6:48 AM, Brian Goetz <brian.go...@oracle.com> wrote:
> 
> What's the L-world story for array subtyping?  For any R-type, R[] <: 
> Object[].  If everything is an L type and everything is <: Object, are arrays 
> of Q-types/primitives also subtypes of Object[]?
> 
> We didn't have a story for this in QU-world either, but at least in QU-world 
> it was believable that QFoo[] <! Object[].  But that seems much less tenable 
> when there's no syntactic difference between L-uses and Q-uses.  (And even 
> less so when we might migrate code from L to Q.)

My two cents: we didn't discuss this in depth, but John raised it in this 
thread, and in the "design notes" document, I followed up with some details.
- Initially, QFoo[] is not a subtype of LFoo[]. You want covariant subtyping, 
you need to stick with L types.
- As an enhancement, we can introduce covariant Q-L subtyping, adjust the 
behavior of aaload/aastore, and explore the performance impact.

What's hard about treating QFoo[] as an LObject[] is that the layout is a 
dynamic property, requiring dynamic checks. But we may also be interested in 
pursuing non-uniform layout for QFoo[] (a specific idea: flattening generally 
but not for "volatile" instances), so there may be some satisfactory coping 
techniques coming.

On Java syntax: who says there's no syntactic difference between L-uses and 
Q-uses? You might spell the L-use "Complex?". But, anyway, that's a question to 
raise in a year, after we better understand the JVM.

—Dan

Reply via email to