File: MyTree.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 (35 lines) | stat: -rw-r--r-- 1,118 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
// Test case for Issue #2686
// https://github.com/typetools/checker-framework/issues/2686

package issue2686;

import org.checkerframework.common.value.qual.StringVal;
import org.checkerframework.common.value.qual.UnknownVal;

public class MyTree<Value> {

    public static <V> MyTree<V> newTree(V value) {
        throw new Error("body doesn't matter");
    }

    public MyTree<Value> put(Value newValue) {
        throw new Error("body doesn't matter");
    }

    void uses() {
        newTree("hello").put("bye");

        MyTree<@UnknownVal String> myTree1 = newTree("hello").put("bye");
        // :: error: (assignment.type.incompatible)
        MyTree<@StringVal("hello") String> myTree2 = newTree("hello").put("hello");
        MyTree<@StringVal("hello") String> myTree2b =
                MyTree.<@StringVal("hello") String>newTree("hello").put("hello");

        MyTree<@UnknownVal String> myTree3 = newTree("hello");
        myTree3.put("bye");

        MyTree<@StringVal("hello") String> myTree4 = newTree("hello");
        // :: error: (argument.type.incompatible)
        myTree4.put("bye");
    }
}