Class KeyForPropagationTreeAnnotator

All Implemented Interfaces:
TreeVisitor<Void,AnnotatedTypeMirror>

public class KeyForPropagationTreeAnnotator extends TreeAnnotator
For the following initializations we wish to propagate the annotations from the left-hand side to the right-hand side or vice versa:

1. If a keySet is being saved to a newly declared set, we transfer the annotations from the keySet to the lhs. e.g.,


 // The user is not required to explicitly annotate the LHS's type argument with @KeyFor("m")
 Set<String> keySet = m.keySet();
 
2. If a variable declaration contains type arguments with an @KeyFor annotation and its initializer is a new class tree with corresponding type arguments that have an @UknownKeyFor primary annotation, we transfer from the LHS to RHS. e.g.,

 // The user does not have to write @KeyFor("m") on both sides
 List<@KeyFor("m") String> keys = new ArrayList<String>();
 
3. IMPORTANT NOTE: The following case must be (and is) handled in KeyForAnnotatedTypeFactory. In BaseTypeVisitor we check to make sure that the constructor called in a NewClassTree is actually compatible with the annotations placed on the NewClassTree. This requires that, prior to this check we also propagate the annotations to this constructor in constructorFromUse so that the constructor call matches the type given to the NewClassTree.
See Also: