File: OverriddenMethodsTest.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 (53 lines) | stat: -rw-r--r-- 1,737 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import testlib.wholeprograminference.qual.*;

class OverriddenMethodsTestParent {
    public void foo(@Sibling1 Object obj, @Sibling2 Object obj2) {}

    public void bar(@Sibling1 OverriddenMethodsTestParent this, @Sibling2 Object obj) {}

    public void barz(@Sibling1 OverriddenMethodsTestParent this, @Sibling2 Object obj) {}

    public void qux(Object obj1, Object obj2) {
        // :: error: argument.type.incompatible
        foo(obj1, obj2);
    }

    public void thud(Object obj1, Object obj2) {
        // :: error: argument.type.incompatible
        foo(obj1, obj2);
    }
}

class OverriddenMethodsTestChild extends OverriddenMethodsTestParent {
    @Override
    public void foo(Object obj, Object obj2) {
        // :: error: (assignment.type.incompatible)
        @Sibling1 Object o = obj;
        // :: error: (assignment.type.incompatible)
        @Sibling2 Object o2 = obj2;
    }

    @Override
    public void bar(Object obj) {
        // :: error: (assignment.type.incompatible)
        @Sibling1 OverriddenMethodsTestChild child = this;
        // :: error: (assignment.type.incompatible)
        @Sibling2 Object o = obj;
    }

    @SuppressWarnings("")
    @Override
    public void barz(Object obj) {}

    public void callbarz(Object obj) {
        // If the @SuppressWarnings("") on the overridden version of barz above is not
        // respected, and the annotations on the receiver and parameter of barz are
        // inferred, then the following call to barz will result in a method.invocation.invalid
        // and an argument.type.incompatible type checking errors.
        barz(obj);
    }

    public void callqux(@Sibling1 Object obj1, @Sibling2 Object obj2) {
        qux(obj1, obj2);
    }
}