Debian Codegraph @

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

raw
1 import testlib.wholeprograminference.qual.*;
2
3 public class PublicFieldTest {
4 public static int field1; // parent
5 public static int field2; // sib2
6
7 public PublicFieldTest() {
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 AnotherClass {
36
37 int innerField;
38
39 public AnotherClass() {
40 PublicFieldTest.field1 = getSibling2();
41 PublicFieldTest.field2 = getSibling2();
42 innerField = getSibling2();
43 }
44
45 void innerFieldTest() {
46 // :: error: (argument.type.incompatible)
47 expectsSibling2(innerField);
48 }
49
50 @WholeProgramInferenceBottom int getBottom() {
51 return (@WholeProgramInferenceBottom int) 0;
52 }
53
54 @Top int getTop() {
55 return (@Top int) 0;
56 }
57
58 @Sibling2 int getSibling2() {
59 return (@Sibling2 int) 0;
60 }
61
62 void expectsSibling2(@Sibling2 int t) {}
63 }