1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
import java.util.Collection;
import testlib.util.*;
public class Values {
void test() {
Object o = get();
Object o1 = get1();
Object o2 = get2();
foo1(o1);
foo2(o2);
// :: error: (argument.type.incompatible)
foo1(o);
// :: error: (argument.type.incompatible)
foo2(o1);
// :: error: (argument.type.incompatible)
foo1(o2);
// :: error: (argument.type.incompatible)
foo(o2);
o1 = o2;
foo2(o1);
// :: error: (argument.type.incompatible)
foo1(o1);
o2 = get1();
foo1(o2);
// :: error: (argument.type.incompatible)
foo2(o2);
}
void andlubTest(Collection<Object> c) {
for (Object obj : c) {
Object o = get1();
}
}
void orlubTest(boolean b1, boolean b2) {
if (b1) {
Object o = get1();
return;
} else if (b2) {
Object o = get2();
return;
}
}
void foo(@Value Object o) {}
void foo1(@Value(1) Object o) {}
void foo2(@Value(2) Object o) {}
@SuppressWarnings("flowtest:return.type.incompatible")
@Value Object get() {
return null;
}
@SuppressWarnings("flowtest:return.type.incompatible")
@Value(1) Object get1() {
return null;
}
@SuppressWarnings("flowtest:return.type.incompatible")
@Value(2) Object get2() {
return null;
}
}
|