File: Issue58Minimization.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,104 kB
  • sloc: java: 145,916; xml: 839; sh: 518; makefile: 404; perl: 26
file content (62 lines) | stat: -rw-r--r-- 1,597 bytes parent folder | download | duplicates (3)
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
import org.checkerframework.checker.index.qual.GTENegativeOne;
import org.checkerframework.checker.index.qual.LTEqLengthOf;
import org.checkerframework.checker.index.qual.LTLengthOf;
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.index.qual.Positive;
import org.checkerframework.checker.index.qual.SameLen;
import org.checkerframework.common.value.qual.MinLen;

class Issue58Minimization {

    void test(@GTENegativeOne int x) {
        int z;
        if ((z = x) != -1) {
            @NonNegative int y = z;
        }
        if ((z = x) != 1) {
            // :: error: (assignment.type.incompatible)
            @NonNegative int y = z;
        }
    }

    void test2(@NonNegative int x) {
        int z;
        if ((z = x) != 0) {
            @Positive int y = z;
        }
        if ((z = x) == 0) {
            // do nothing
            int y = 5;
        } else {
            @Positive int y = x;
        }
    }

    void ubc_test(int[] a, @LTEqLengthOf("#1") int x) {
        int z;
        if ((z = x) != a.length) {
            @LTLengthOf("a") int y = z;
        }
    }

    void samelen_test(int[] a, int[] c) {
        int[] b;
        if ((b = a) == c) {
            int @SameLen({"a", "b", "c"}) [] d = b;
        }
    }

    void minlen_test(int[] a, int @MinLen(1) [] c) {
        int[] b;
        if ((b = a) == c) {
            int @MinLen(1) [] d = b;
        }
    }

    void minlen_test2(int[] a, int x) {
        int one = 1;
        if ((x = one) == a.length) {
            int @MinLen(1) [] b = a;
        }
    }
}