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
|
import org.checkerframework.checker.index.qual.GTENegativeOne;
import org.checkerframework.checker.index.qual.LowerBoundUnknown;
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.index.qual.Positive;
class LBCSubtyping {
void foo() {
@GTENegativeOne int i = -1;
@LowerBoundUnknown int j = i;
int k = -4;
// not this one though
// :: error: (assignment.type.incompatible)
@GTENegativeOne int l = k;
@NonNegative int n = 0;
@Positive int a = 1;
// check that everything is aboveboard
j = a;
j = n;
l = n;
n = a;
// error cases
// :: error: (assignment.type.incompatible)
@NonNegative int p = i;
// :: error: (assignment.type.incompatible)
@Positive int b = i;
// :: error: (assignment.type.incompatible)
@NonNegative int r = k;
// :: error: (assignment.type.incompatible)
@Positive int c = k;
// :: error: (assignment.type.incompatible)
@Positive int d = r;
}
}
// a comment
|