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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
import org.checkerframework.checker.index.qual.IndexFor;
import org.checkerframework.checker.index.qual.LTEqLengthOf;
import org.checkerframework.checker.index.qual.LTLengthOf;
// @skip-test until we bring list support back
// @skip-test can't handle until TreeUtils.getMethod has a way to precisly handle method overloading
class ListRemove {
List<Integer> listField;
void ListRemove(
@LTLengthOf("#3") int index, @LTEqLengthOf("#3") int notIndex, List<Integer> list) {
list.remove(index);
// :: error: (list.access.unsafe.high)
list.remove(notIndex);
}
void ListRemoveWrongName(@LTLengthOf("arr") int index, List<Integer> list) {
// :: error: (list.access.unsafe.high)
list.remove(index);
}
void ListRemoveField() {
listField.remove(listField.size() - 1);
listField.remove(this.listField.size() - 1);
this.listField.remove(listField.size() - 1);
this.listField.remove(this.listField.size() - 1);
// :: error: (list.access.unsafe.high)
listField.remove(listField.size());
// :: error: (list.access.unsafe.high)
listField.remove(this.listField.size());
// :: error: (list.access.unsafe.high)
this.listField.remove(listField.size());
// :: error: (list.access.unsafe.high)
this.listField.remove(this.listField.size());
}
void ListRemoveFieldUserAnnotation(@IndexFor("listField") int i) {
listField.remove(i);
this.listField.remove(i);
// :: error: (list.access.unsafe.high)
listField.remove(i + 1);
// :: error: (list.access.unsafe.high)
this.listField.remove(i + 1);
}
void ListRemoveUserAnnotation(@IndexFor("list") int i, List<Integer> list) {
list.remove(i);
// :: error: (list.access.unsafe.high)
list.remove(i + 1);
// :: error: (list.access.unsafe.high)
list.remove(i);
}
void FailRemove(List<Integer> list) {
@LTLengthOf("list") int i = list.size() - 1;
try {
list.remove(1);
} catch (Exception e) {
}
@LTLengthOf("list") int m = i;
}
void RemoveUpdate(List<Integer> list) {
@LTLength("list")
int m = list.size() - 1;
list.get(m);
list.remove(m);
// :: error: (list.access.unsafe.high)
list.get(m);
}
}
|