File: StringPatternsUsage.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-- 926 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
import testlib.util.*;

public class StringPatternsUsage {

    void requiresA(@PatternA String arg) {}

    void requiresB(@PatternB String arg) {}

    void requiresC(@PatternC String arg) {}

    void requiresAB(@PatternAB String arg) {}

    void requiresBC(@PatternBC String arg) {}

    void requiresAC(@PatternAC String arg) {}

    void requiresAny(String arg) {}

    void m() {

        String a = "A";
        String b = "B";
        String c = "C";
        String d = "D";
        String e = "";

        // This should produce the following diagnostic:
        // :-1: other: error: Bug in @ImplicitFor(stringpatterns=...) in type hierarchy definition:
        // inferred type for "A" is [@PatternBottomPartial] which is a subtype of [@PatternBC] but
        // its pattern does not match the string.  matches = [[@PatternAC], [@PatternAB]];
        // nonMatches = [[@PatternBC]]

        requiresA(a);
    }
}