biddyweb / checker-framework

Automatically exported from code.google.com/p/checker-framework
Other
0 stars 1 forks source link

ArrayList constructor and KeyFor for parameters #415

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
ArrayList constructor and KeyFor for parameters

I wish to invoke the ArrayList constructor on a set whose elements are 
annotated with @KeyFor.

This works when the @KeyFor argument is a field, as in method usesField().
This does not work when the @KeyFor argument is a parameter, as in method 
usesParameter().

See the attached test case.

  Map<String,Integer> mymap = new HashMap<String,Integer>();

  public static void usesField(Set</*@KeyFor("this.mymap")*/ String> keySet) {
    new ArrayList</*@KeyFor("this.mymap")*/ String> (keySet);
  }

  public static void usesParameter(Map<String,Integer> m, Set</*@KeyFor("#1")*/ String> keySet) {
    new ArrayList</*@KeyFor("#1")*/ String> (keySet);
  }

Original issue reported on code.google.com by michael.ernst@gmail.com on 19 Mar 2015 at 2:41

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by Jonathan...@gmail.com on 8 Apr 2015 at 9:47

GoogleCodeExporter commented 9 years ago

Original comment by jtha...@cs.washington.edu on 18 Apr 2015 at 6:42