[Checkers] r2622: modifying visitNewClass on TypeFromTree
Mahmood Ali
mahmood at MIT.EDU
Wed Jun 4 12:54:54 EDT 2008
Hi Telmo,
Currently, the framework does not do anything creative about that.
Before your check-in, it merely added the annotations found in the new
class tree. The individual checkers have the responsibilities of
inserting such annotation (check
IGJAnnotatedTypeFactory.IGJTreePreAnnotator for such example). In
other words, for your example, it only returned @A SomeObject.
I am imagining the framework to do two extra things:
1. QualifierHierarchy (a.k.a. AnnotationRelations) - relatively a new
class - expose the hierarchy of qualifiers. The framework could
simply insert non-contradictory qualifiers. So no individual checkers
needs to override that behavior.
2. Check that the user-specified qualifier in the new class is a valid
supertype of the constructor receiver. So one wouldn't have new
@Immutable FOO() when the constructor is defined as 'FOO() @Mutable
{ }'.
Hopefully that helps.
Regards,
Mahmood
On Jun 4, 2008, at 12:02 PM, Telmo wrote:
> Oh. I wasn't aware of the possibility of adding annotations between
> new and the new class name.
>
> What annotations should be added to the new object, though? Namely,
> if one writes
>
> new @A SomeObject();
>
> and the constructor of SomeObject takes the form
>
> SomeObject() @B { ... }
>
> should the created type have both the @A and @B annotations?
>
> -Telmo
>
>
> On Tue, 3 Jun 2008, Mahmood Ali wrote:
>
>> Hi Telmo again,
>>
>> I reviewed your code, and it is a bit buggy. I just checked in two
>> failing cases: a framework (to test
>> AnnotatedTypeFactory.constructorFromUse) and a Javari test (to test
>> JavariAnnotatedTypeFactory.constructorFromUse).
>>
>> The offending lines are:
>>> Map<? extends AnnotatedTypeMirror, AnnotatedTypeMirror>
>>> receiverTypeMap
>>> = Collections.singletonMap<exType.getReceiverType(), type);
>>> return exType.substitute(receiverTypeMap);
>>
>> You may only substitute polymorphic annotation and nothing else!
>>
>> - Mahmood
More information about the checkers
mailing list