Debian Codegraph @

framework/tests/whole-program-inference/non-annotated/Anonymous.java

raw
1 import testlib.wholeprograminference.qual.*;
2
3 public class Anonymous {
4 public static int field1; // parent
5 public static int field2; // sib2
6
7 public Anonymous() {
8 field1 = getSibling1();
9 }
10
11 void testPublicInference() {
12 // :: error: (argument.type.incompatible)
13 expectsSibling2(field2);
14 // :: error: (argument.type.incompatible)
15 expectsParent(field1);
16 // :: error: (argument.type.incompatible)
17 expectsParent(field2);
18 }
19
20 void expectsBottom(@WholeProgramInferenceBottom int t) {}
21
22 void expectsSibling1(@Sibling1 int t) {}
23
24 void expectsSibling2(@Sibling2 int t) {}
25
26 void expectsTop(@Top int t) {}
27
28 void expectsParent(@Parent int t) {}
29
30 @Sibling1 int getSibling1() {
31 return (@Sibling1 int) 0;
32 }
33 }
34
35 class UsesAnonymous {
36 void method() {
37 Anonymous a =
38 new Anonymous() {
39 int innerField;
40
41 public void method2() {
42 Anonymous.field1 = getSibling2();
43 Anonymous.field2 = getSibling2();
44 innerField = getSibling2();
45 }
46
47 void innerFieldTest() {
48 // :: error: (argument.type.incompatible)
49 expectsSibling2(innerField);
50 }
51
52 @WholeProgramInferenceBottom int getBottom() {
53 return (@WholeProgramInferenceBottom int) 0;
54 }
55
56 @Top int getTop() {
57 return (@Top int) 0;
58 }
59
60 @Sibling2 int getSibling2() {
61 return (@Sibling2 int) 0;
62 }
63
64 void expectsSibling2(@Sibling2 int t) {}
65 };
66 }
67 }