JDK 13 RFR of JDK-8224687: Add clarifying overrides of Element.asType to more specific subinterfaces

Ron Shapiro ronshapiro at google.com
Thu May 30 17:44:05 UTC 2019


Is it within scope to return the specific subtypes as covariant return
types? e.g. TypeParameterElement could return TypeVariable, TypeElement
could return DeclaredType, etc.

On Thu, May 30, 2019 at 1:25 PM Jonathan Gibbons <
jonathan.gibbons at oracle.com> wrote:

>
>
> On 05/30/2019 10:15 AM, Jonathan Gibbons wrote:
> >
> >
> > On 05/29/2019 05:24 PM, Joe Darcy wrote:
> >> Hello,
> >>
> >> Please review the webrev and CSR for:
> >>
> >>     JDK-8224687: Add clarifying overrides of Element.asType to more
> >> specific subinterfaces
> >>     webrev: http://cr.openjdk.java.net/~darcy/8224687.2/
> >>     CSR: https://bugs.openjdk.java.net/browse/JDK-8225027
> >>
> >> Thanks,
> >>
> >> -Joe
> >>
> >
> > Joe,
> >
> > CSR Reviewed.
> >
> > In the new test, I don't understand lines 119, 128, regarding
> > ElementKind.FIELD.
> > Either the code is a copy-paste error, or the description elsewhere of
> > DeclaredType
> > and TypeKind.DECLARED is incorrect, since these only refer to declared
> > types
> > (class, interface, etc) and not fields.
> >
> > Surprising or maybe not, the test actually passes, suggesting that
> > this is the
> > current behavior even if it is unexpected.  That being said, the
> > output from the
> > test would be easier to understand if it included the ElementKind and
> > simple name
> > of the element, as well as the typeMirror, typeMirror class and typeKind.
> >
> > -- Jon
>
> I guess what is happening is that the mapping to TypeMirror for
> ElementKind.FIELD
> varies, depending on the field being declared. If so, that deserves
> mention in the
> spec for VariableElement.asType, and also deserves a comment in the test
> code.
> I'll stop short of suggesting that the test code should have more fields
> in it, such as
> a field of primitive type, but if you could find an easy way to adapt
> the test for that,
> that would be good too.
>
> -- Jon
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20190530/c1cd6700/attachment-0001.html>


More information about the compiler-dev mailing list