File: KeyForPolymorphism.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 (19 lines) | stat: -rw-r--r-- 590 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
import java.util.HashMap;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.*;

// test related to issue 429: https://github.com/typetools/checker-framework/issues/429
class KeyForPolymorphism {

    Map<String, Object> m1 = new HashMap<>();
    Map<String, Object> m2 = new HashMap<>();

    void method(@KeyFor("m1") String k1m1, @KeyFor("m2") String k1m2) {
        @KeyFor("m1") String k2m1 = identity1(k1m1);
        @KeyFor("m2") String k2m2 = identity1(k1m2);
    }

    static @PolyKeyFor String identity1(@PolyKeyFor String arg) {
        return arg;
    }
}