ctolkmit / checker-framework

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

Issue with inferred annotations and the diamond operator #289

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The nullness checker reports an 'incompatible types in assignment error' for 
the follow snippet. Should I expect the diamond operator to work with annotated 
types?

Tested with version javac 1.8.0-jsr308-1.7.1

===

import checkers.nullness.quals.*;

import java.util.List;
import java.util.ArrayList;

class Diamond {
  void f() {
    List<@Nullable Object> c = new ArrayList<>();
  }
}

===

Original issue reported on code.google.com by cus...@google.com on 12 Dec 2013 at 6:39

GoogleCodeExporter commented 9 years ago
Having diamond operator support for only simple inference scenarios would still 
be very useful. Most usages of the operator I've seen are with classes whose 
constructors do not define type arguments, and almost half of the usages are 
just "new ArrayList<>()".

Original comment by cus...@google.com on 18 Dec 2013 at 5:38

GoogleCodeExporter commented 9 years ago

Original comment by wdi...@gmail.com on 1 Jan 2014 at 9:06

GoogleCodeExporter commented 9 years ago
I've added test case tests/nullness/Issue289.java and the code should now work 
for simple examples.
More complex examples might still break and need more experiments.
After a few other refactorings we should re-visit diamond inference.
Please do let us know if you have specific examples that don't work.

Original comment by wdi...@gmail.com on 2 Jan 2014 at 1:24

GoogleCodeExporter commented 9 years ago

Original comment by Jonathan...@gmail.com on 6 Jan 2014 at 6:53