File: SLSubtyping.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 (24 lines) | stat: -rw-r--r-- 640 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
import org.checkerframework.checker.index.qual.SameLen;

// This test checks whether the SameLen type system works as expected.

class SLSubtyping {
    int[] f = {1};

    void subtype(int @SameLen("#2") [] a, int[] b) {
        int @SameLen({"a", "b"}) [] c = a;

        // :: error: (assignment.type.incompatible)
        int @SameLen("c") [] q = {1, 2};
        int @SameLen("c") [] d = q;

        // :: error: (assignment.type.incompatible)
        int @SameLen("f") [] e = a;
    }

    void subtype2(int[] a, int @SameLen("#1") [] b) {
        a = b;
        int @SameLen("b") [] c = b;
        int @SameLen("f") [] d = f;
    }
}