interactions between type annotations and language model APIs.

Eric McCorkle eric.mccorkle at
Mon May 5 20:36:21 UTC 2014

An additional question I would like to raise deals with the relationship
between type annotations and subtyping.

Offhand, there are four possible ways by which annotations might
interact with subtying:  covariance (the annotation is preserved for all
subtypes, but not supertypes), contravariance (the annotation is
preserved for all supertypes, but not subtypes), anyvariance (the
annotation is preserved for both super- and subtypes), and invariance
(the annotation is not preserved).

Additionally, there's the question of whether for some interface I and
annotation @A, one can have both I and @A I in an interface heirarchy.

I'll put forward that type annotations need to be able to support all
these possibilities, and that there ought to be additional facilities
for defining how a given annotation type behaves in these contexts.

These are all future-facing considerations, of course.  I'm mentioning
them here because they came up in discussions of the issues Jon raised,
but they do not need to be addressed in the same timeline.

On 05/05/14 15:52, Jonathan Gibbons wrote:
> In cleaning up the reference implementation of type annotations, we've
> uncovered some questions pertaining to the interactions between the type
> annotations and language model APIs.
> In particular, TypeMirror is now an AnnotatedConstruct, and various
> methods in javax.lang.model.util.Types return computed TypeMirrors --
> for example, capture(TypeMirror), directSupertypes(TypeMirror),
> erasure(TypeMirror), etc.
> In cases where the argument has type annotations, what type annotations
> (if any) should appear on the return value?
> It would help to see clarification added to the specifications, either
> generally, or on a case-by-case basis for the affected methods.
> -- Jon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eric_mccorkle.vcf
Type: text/x-vcard
Size: 303 bytes
Desc: not available
URL: <>

More information about the compiler-dev mailing list