File: GLBTest.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,840 kB
  • sloc: java: 145,910; xml: 839; sh: 518; makefile: 401; perl: 26
file content (25 lines) | stat: -rw-r--r-- 1,472 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
import org.checkerframework.common.reflection.qual.ClassBound;
import org.checkerframework.common.reflection.qual.ClassVal;

class GLBTest<@ClassVal({"A", "B"}) T extends Object> {
    // This code is intented to cover the more complex branchs for the GLB calcuation.
    // This only triggers the GLB calculation because of a hack in
    // org.checkerframework.framework.util.AnnotatedTypes.addAnnotationsImpl()
    // If that code changes, this code may not test GLB anymore.
    // This code does not test correctness. Because no expresion is given the GLB as a type,
    // it is impossible to test GLB for correctness.
    // :: error: (type.argument.type.incompatible) :: error: (assignment.type.incompatible)
    GLBTest<@ClassVal({"A", "B", "C"}) ?> f1 = new GLBTest<@ClassVal({"A", "E"}) Object>();
    // :: error: (type.argument.type.incompatible) :: error: (assignment.type.incompatible)
    GLBTest<@ClassVal({"A", "B", "C"}) ?> f2 = new GLBTest<@ClassBound({"A", "E"}) Object>();
    // :: error: (type.argument.type.incompatible) :: error: (assignment.type.incompatible)
    GLBTest<@ClassBound({"A", "B", "C"}) ?> f3 = new GLBTest<@ClassBound({"A", "E"}) Object>();

    <
                    @ClassVal({"A", "B", "C"}) CLASSVAL extends Object,
                    @ClassBound({"A", "B", "C"}) CLASSBOUND extends Object>
            void test() {
        GLBTest<?> f1 = new GLBTest<CLASSVAL>();
        GLBTest<?> f2 = new GLBTest<CLASSBOUND>();
    }
}