spec clarification: type annotations on static nested types

Liam Miller-Cushon cushon at google.com
Tue Dec 11 22:28:48 UTC 2018


On Tue, Dec 11, 2018 at 12:04 PM Alex Buckley <alex.buckley at oracle.com>
wrote:

> On 12/10/2018 6:14 PM, Liam Miller-Cushon wrote:
> > On Mon, Dec 10, 2018 at 2:57 PM Alex Buckley <alex.buckley at oracle.com
> > <mailto:alex.buckley at oracle.com>> wrote:
> >
> >     To avoid confusion, the rule should be: "If the value of path_length
> is
> >     0, and the type being annotated is a nested type, then the annotation
> >     applies to the outermost [DELETE]enclosing[/DELETE] part of the type
> >     for which a type annotation is admissible."
> ...
> >
> > Does "outermost part of a type" refer to the idea of enclosing/nested
> > types in general, or just in this specific context since we're only
> > talking about nested types? Put another way, is it meaningful to talk
> > about the 'outermost part' of arbitrary types?
>
> Words based on "inner" and "outer" connect most strongly with nested
> types, where the containment relation is clear from the declaration
> site. Still, I can imagine that "outermost part" could be ascribed
> meaning for a array type or a parameterized type, where the containment
> exists but is driven by the use site. For example, given a use of the
> type T[][], the outermost type is T[][] and the innermost type is T;
> given a use of the type A<B<C>>, the outermost type is A<..> and the
> innermost type is C. This would specify the meaning of a non-zero
> path_length more firmly than "... each entry in the path array
> represents an iterative, left-to-right step towards the precise location
> of the annotation in an array type, nested type, or parameterized type".
> Is that the direction you were heading in?
>

It was, it seemed like it might be a way to avoid special-casing nested
types:

"If the value of path_length is 0 then the annotation applies to the
outermost
part of the type for which a type annotation is admissible."

Regarding that "left-to-right step" part, I was struggling a bit with it
earlier.
Is left and right referring to the position in the type_path structure
itself,
or in the canonical string representation of the type, or perhaps in the
type descriptor?

Assuming an example like 4.7.20.2-C, we step in to the array type like so:

String *[]* [] []
       ^

String [] *[]* []
          ^

String [] [] *[]*
             ^

*String* [] [] []
^

Thinking of that as "left-to-right" seems confusing.

It works better applied to the type descriptor, but the rest of 4.7.20.2
talks about types more abstractly.

*[*[[Ljava/lang/String;
^

[*[*[Ljava/lang/String;
 ^

[[*[*Ljava/lang/String;
  ^

[[[*Ljava/lang/String;*
   ^

What do you think about trying to use the idea of containment more
extensively in 4.7.20.2?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20181211/69826e87/attachment.html>


More information about the compiler-dev mailing list