[Checkers] AnnotatedTypeMirror is not sufficiently unique

Artemus Harper subanark at gmail.com
Fri Oct 3 01:20:44 EDT 2008

>  For example there is no way to determine the difference between the return
>> types of methods that have the same type and same annotations. This causes
>> me a problem since I want to be able to retrieve additional information on
>> an AnnotatedType (in particular the receiver of the method, if any, that is
>> scope with the deceleration)
> You can AnnotatedExecutableType.getElement() to differentiate between them.
>  You can only use this with method executable type rather than the return or
> the receiver type.
> - Mahmood
For return values and receivers the getElement() will return null as there
is no Element for this (as noted in #2). ExecutableElement has a
getReturnType() method which provides a TypeMirror, but as far as I know
there is no Element representation for a return type.

If I can get a unique AnnotatedTypeMirror for a Tree or Element, then I can
create an identity map that maps those to the method receiver in the
annotateImplicit methods. This allows me to latter look them up in cases
where I only have the AnnotatedTypeMirror (as with the isSubtype method in
the BaseTypeChecker).

Since AnnotatedTypeFactory.getAnnotatedType caches results and provides
copies of the cache when called I don't have the opturnity to map this value
without overriding the getAnnotatedType method.

The reason I assumed that AnnotatedTypeMirror was to be unique for each
Element is that they have a getElement method. I'm at a loss why there is
this method at all if the AnnotatedTypeMirror is just to wrap the TypeMirror
and disregard the element property which may be different for "equal" types.

Artemus Harper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.csail.mit.edu/mailman/private/checkers/attachments/20081002/fc350254/attachment.htm 

More information about the checkers mailing list