Debian Codegraph @

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

raw
1 import testlib.wholeprograminference.qual.*;
2
3 class OverriddenMethodsTestParent {
4 public void foo(@Sibling1 Object obj, @Sibling2 Object obj2) {}
5
6 public void bar(@Sibling1 OverriddenMethodsTestParent this, @Sibling2 Object obj) {}
7
8 public void barz(@Sibling1 OverriddenMethodsTestParent this, @Sibling2 Object obj) {}
9
10 public void qux(Object obj1, Object obj2) {
11 // :: error: argument.type.incompatible
12 foo(obj1, obj2);
13 }
14
15 public void thud(Object obj1, Object obj2) {
16 // :: error: argument.type.incompatible
17 foo(obj1, obj2);
18 }
19 }
20
21 class OverriddenMethodsTestChild extends OverriddenMethodsTestParent {
22 @Override
23 public void foo(Object obj, Object obj2) {
24 // :: error: (assignment.type.incompatible)
25 @Sibling1 Object o = obj;
26 // :: error: (assignment.type.incompatible)
27 @Sibling2 Object o2 = obj2;
28 }
29
30 @Override
31 public void bar(Object obj) {
32 // :: error: (assignment.type.incompatible)
33 @Sibling1 OverriddenMethodsTestChild child = this;
34 // :: error: (assignment.type.incompatible)
35 @Sibling2 Object o = obj;
36 }
37
38 @SuppressWarnings("")
39 @Override
40 public void barz(Object obj) {}
41
42 public void callbarz(Object obj) {
43 // If the @SuppressWarnings("") on the overridden version of barz above is not
44 // respected, and the annotations on the receiver and parameter of barz are
45 // inferred, then the following call to barz will result in a method.invocation.invalid
46 // and an argument.type.incompatible type checking errors.
47 barz(obj);
48 }
49
50 public void callqux(@Sibling1 Object obj1, @Sibling2 Object obj2) {
51 qux(obj1, obj2);
52 }
53 }