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);
}
}
|