File: Issue273.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 (26 lines) | stat: -rw-r--r-- 779 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
// Test case for issue #273:
// https://github.com/typetools/checker-framework/issues/273

import java.util.HashMap;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.*;

class Issue273 {
    public static void main(String... p) {
        Map<String, Integer> m0 = new HashMap<>();
        Map<String, Integer> m1 = new HashMap<>();
        @SuppressWarnings("assignment.type.incompatible")
        @KeyFor("m0") String k = "key";
        m0.put(k, 1);

        // :: error: (argument.type.incompatible)
        getMap2(m0, m1, k).toString();
    }

    public static @NonNull Integer getMap2(
            Map<String, Integer> m1, // m1,m0 flipped
            Map<String, Integer> m0,
            @KeyFor("#2") String k) {
        return m0.get(k);
    }
}