typetools / checker-framework-inference

Inference of pluggable types for Java
10 stars 33 forks source link

Annotations on class declaration extends #10

Open smillst opened 8 years ago

smillst commented 8 years ago

We currently don't support annotations on implicit extends for class declarations see comment on: VariableAnnotator#createImpliedExtendsLocation(com.sun.source.tree.ClassTree) And according to the email exchange below, we should not.

smillst commented 8 years ago

This is the portion of the email exchange that is relevant to this issue. (The rest of the email is reported in #11)


From: Jonathan Burke

How do these annotations relate to annotations on an extends bound?

@Anno1 class MyClass extends @Anno2 BaseClass {}

Thanks, Jonathan


From: Michael Ernst

Jonathan-

The other question to go along with this is, how do these annotations relate to annotations on an extends bound?

@Anno1 class MyClass extends @Anno2 BaseClass {}

I would think that the annotations (explicit/implicit/defaulted) would need to satisfy the relationship >@Anno1 <: @Anno2.

-Mike


From: Werner Dietl

Jonathan, all,

what is the meaning of an annotation on a superclass or superinterface at all? They are not "extends bounds" - they don't restrict instantiations.

In

@Anno1 class MyClass extends @Anno2 BaseClass
  implements @Anno3 BaseItf {
}

When do we use @Anno2 and @Anno3?

I think at the moment these two annotations are not used at all and adding the checks

@Anno1 <: @Anno2 @Anno1 <: @Anno3

seems not very useful.

I think @Anno1, the annotation on the class declaration, should also be used for the type of "this" in the class body - for the locations where no method receiver can be specified - e.g. for fields and instance initializer blocks.

@Anno2 and @Anno3 might be useful for well-formedness checking of the superclass/superinterface type. However, do we have examples where @Anno1 should not be used for this?

cu, WMD.