| 1 |
import org.checkerframework.common.value.qual.*; |
| 2 |
|
| 3 |
public class TransferAdd { |
| 4 |
|
| 5 |
void test() { |
| 6 |
|
| 7 |
// adding zero and one and two |
| 8 |
|
| 9 |
int a = -1; |
| 10 |
|
| 11 |
@IntRange(from = 1) int a1 = a + 2; |
| 12 |
|
| 13 |
@IntRange(from = 0) int b = a + 1; |
| 14 |
@IntRange(from = 0) int c = 1 + a; |
| 15 |
|
| 16 |
@IntRange(from = -1) int d = a + 0; |
| 17 |
@IntRange(from = -1) int e = 0 + a; |
| 18 |
|
| 19 |
// :: error: (assignment.type.incompatible) |
| 20 |
@IntRange(from = 1) int f = a + 1; |
| 21 |
|
| 22 |
@IntRange(from = 0) int g = b + 0; |
| 23 |
|
| 24 |
@IntRange(from = 1) int h = b + 1; |
| 25 |
|
| 26 |
@IntRange(from = 1) int i = h + 1; |
| 27 |
@IntRange(from = 1) int j = h + 0; |
| 28 |
|
| 29 |
// adding values |
| 30 |
|
| 31 |
@IntRange(from = 1) int k = i + j; |
| 32 |
// :: error: (assignment.type.incompatible) |
| 33 |
@IntRange(from = 1) int l = b + c; |
| 34 |
// :: error: (assignment.type.incompatible) |
| 35 |
@IntRange(from = 1) int m = d + c; |
| 36 |
// :: error: (assignment.type.incompatible) |
| 37 |
@IntRange(from = 1) int n = d + e; |
| 38 |
|
| 39 |
@IntRange(from = 1) int o = h + g; |
| 40 |
// :: error: (assignment.type.incompatible) |
| 41 |
@IntRange(from = 1) int p = h + d; |
| 42 |
|
| 43 |
@IntRange(from = 0) int q = b + c; |
| 44 |
// :: error: (assignment.type.incompatible) |
| 45 |
@IntRange(from = 0) int r = q + d; |
| 46 |
|
| 47 |
@IntRange(from = 0) int s = k + d; |
| 48 |
@IntRange(from = -1) int t = s + d; |
| 49 |
|
| 50 |
// increments |
| 51 |
|
| 52 |
// :: error: (assignment.type.incompatible) |
| 53 |
@IntRange(from = 1) int u = b++; |
| 54 |
|
| 55 |
@IntRange(from = 1) int u1 = b; |
| 56 |
|
| 57 |
@IntRange(from = 1) int v = ++c; |
| 58 |
|
| 59 |
@IntRange(from = 1) int v1 = c; |
| 60 |
|
| 61 |
int n1p1 = -1, n1p2 = -1; |
| 62 |
|
| 63 |
@IntRange(from = 0) int w = ++n1p1; |
| 64 |
|
| 65 |
@IntRange(from = 0) int w1 = n1p1; |
| 66 |
|
| 67 |
// :: error: (assignment.type.incompatible) |
| 68 |
@IntRange(from = 1) int w2 = n1p1; |
| 69 |
// :: error: (assignment.type.incompatible) |
| 70 |
@IntRange(from = 1) int w3 = n1p1++; |
| 71 |
|
| 72 |
// :: error: (assignment.type.incompatible) |
| 73 |
@IntRange(from = 0) int x = n1p2++; |
| 74 |
|
| 75 |
@IntRange(from = 0) int x1 = n1p2; |
| 76 |
|
| 77 |
// :: error: (assignment.type.incompatible) |
| 78 |
@IntRange(from = 1) int y = ++d; |
| 79 |
// :: error: (assignment.type.incompatible) |
| 80 |
@IntRange(from = 1) int z = e++; |
| 81 |
} |
| 82 |
} |