Skip to content

Enable @PolyAll to work for the @KeyFor hierarchy #429

@GoogleCodeExporter

Description

@GoogleCodeExporter
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions