biddyweb / checker-framework

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

Nullness checker rejects valid program #428

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If javac accepts this code, the checker should also. (Unless it's a javac bug, 
but I don't think it is.)

Tested with jenkins build #272.

=== Test.java ===
import java.util.List;

interface I<T extends Number> {}

class Test {
  void m(List<I<? extends Object>> is) {
    I<?> i = is.get(0);
  }
}
===

$ ./checker/bin/javac  ~/Test.java
... builds successfully

$ ./checker/bin/javac -processor 
org.checkerframework.checker.nullness.NullnessChecker ~/Test.java
/usr/local/google/home/cushon/Test.java:7: error: 
[assignment.type.incompatible] incompatible types in assignment.
    I<?> i = is.get(0);
                   ^
  found   : I<?[ extends Object super Void]>
  required: I<?[ extends Number super Void]>
1 error

Original issue reported on code.google.com by cus...@google.com on 14 Apr 2015 at 6:06

GoogleCodeExporter commented 9 years ago
I agree.  This particular issue comes because the wildcard bound is explicitly 
set outside of the bound of the type parameter (that is ? extends Object is 
technically outside of the bounds of T).  However, this doesn't actually matter 
since you cannot construct an instance of I that violates those bounds.

This should indeed typecheck.  

Original comment by jbu...@cs.washington.edu on 14 Apr 2015 at 6:23