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 36 37 38 39 40 41 42 43 44 45
|
// Test case for issue #2358: https://tinyurl.com/cfissue/#2358
// @skip-test until the bug is fixed.
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.checkerframework.checker.nullness.qual.KeyFor;
public class KeyForMultiple {
void m1() {
Map<@KeyFor({"sharedBooks"}) String, Integer> sharedBooks = new HashMap<>();
Map<@KeyFor({"sharedBooks"}) String, Integer> sharedCounts1 = new HashMap<>();
Set<@KeyFor({"sharedCounts1"}) String> sharedCountsKeys1 = sharedCounts1.keySet();
}
void m2() {
Map<@KeyFor({"sharedBooks"}) String, Integer> sharedBooks = new HashMap<>();
Map<@KeyFor({"sharedBooks"}) String, Integer> sharedCounts1 = new HashMap<>();
Set<@KeyFor({"sharedBooks", "sharedCounts1"}) String> otherChars1 = sharedCounts1.keySet();
}
void m3() {
Map<@KeyFor({"sharedBooks"}) String, Integer> sharedBooks = new HashMap<>();
Map<@KeyFor({"sharedBooks", "sharedCounts2"}) String, Integer> sharedCounts2 =
new HashMap<>();
Set<@KeyFor({"sharedCounts2"}) String> sharedCountsKeys2 = sharedCounts2.keySet();
}
void m4() {
Map<@KeyFor({"sharedBooks"}) String, Integer> sharedBooks = new HashMap<>();
Map<@KeyFor({"sharedBooks", "sharedCounts2"}) String, Integer> sharedCounts2 =
new HashMap<>();
Set<@KeyFor({"sharedBooks", "sharedCounts2"}) String> otherChars2 = sharedCounts2.keySet();
}
}
|