Given the following code, it should be possible to remove the @SuppressWarnings
and instead annotate nounSubset as @PolyAll in its argument and return value,
so that @PolyAll can capture the need to annotate them with @KeyFor("dict") at
the call site.
Note: Remove the link to this issue from the manual once this issue is fixed.
Map<String, String> dict; // English dictionary. Maps words to their
definitions.
// Method nounSubset's declaration uses no @KeyFor annotations
// because in addition to being used by the dictionary feature,
// it is also used by a spell checker that only stores sets of words
// and does not use the notions of dictionaries, maps, or keys.
public Set<String> nounSubset(Set<String> words) { ... }
void outputAllNounDefinitions() {
@SuppressWarnings("keyfor") // argument elements are @KeyFor("dict"), so result elements are too
Set<@KeyFor("dict") String> nounSet = nounSubset(dict.keySet());
for (@KeyFor("dict") String noun : nounSet) {
String definition = dict.get(noun);
System.out.println(noun + ": " + definition);
}
}
Original issue reported on code.google.com by jtha...@cs.washington.edu on 16 Apr 2015 at 7:47
Original issue reported on code.google.com by
jtha...@cs.washington.edu
on 16 Apr 2015 at 7:47