[Checkers] PolymorphiQualifier and QualifierHierarchy

Mahmood Ali mahmood at MIT.EDU
Mon Jun 16 18:53:47 EDT 2008


I wanted to discuss the issue of Polymorphic qualifiers and the type  
hierarchy over email.

The quoted text is Mike's comments in TODO.txt

> These meta-annotations on PolyInterned (and similar ones on  
> PolyNull, etc.)
> look funny to me.
>  @PolymorphicQualifier
>  @SubtypeOf({Unqualified.class})
> I don't really think of PolyInterned as being a type qualifier in  
> the type
> hierarchy, nor as being a subtype of no-annotation (Unqualified).

In a sense, all type systems have the polymorphic qualifier as part of  
the qualifier hierarchy; where the qualifier is a supertype is a super- 
qual of the bottom qualifier.

All bottom qualifiers in the current checkers are subtype of the  
polymorphic qualifier: NonNull in Nullness, Interned in Interning, and  
similarly Mutable in Javari, and IGJBottom in IGJ.  Currently we  
specify this subtype relationship (I forgot to do that for nonnull and  
interning) through SubtypeOf for the subtypes.  Thus, I don't see it  
quite weird to specify the polymorphic qualifier superquals.

Bare in mind, that I am treating the polymorphic qualifiers just like  
type variables (where the upper bound is always the root).

> Would it be more natural to write the annotation as
>  @PolymorphicQualifier({Interned.class, Unqualified.class})
> and the meta-annotation on PolyNull as
>  @PolymorphicQualifier({ Nullable.class, NonNull.class })
> ?  What are the pros and cons of that?

I find this syntax a bit confusing.  It either means (for PolyNull for  
1. PolyNull belongs to same qualifier hierarchy as Nullable and  
NonNull.  This information is already provided as TypeQualifiers value  
annotating the checker.

2. PolyNull can only template over Nullable and NonNull (excluding  
Raw, even missed un-intentionally).  Is there much value in having the  
qualifier template over a subset of the qualifiers?  If so, then I  
would like to go for it; otherwise, I don't feel strongly about it.

My proposal:
Simply declare the polymorphic qualifier as such without specifying  
the root.  DAGQualifierHierarchy would add the relationship between  
polymorphic qualifier and the root automatically (just like how we did  
it before).


More information about the checkers mailing list