mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-11 20:07:01 +07:00
- update language levels partially - fix tests (cherry picked from commit 8d7b599772eda8dfd999bee9f816ec2609be4adb) (cherry picked from commit 98a507ba78b8fc496651b5800fc3936c9c87b689) IJ-MR-169535 GitOrigin-RevId: 898e8b4dfc303eb60da6cfff5d756304c461c424
47 lines
1.1 KiB
Java
47 lines
1.1 KiB
Java
import java.util.List;
|
|
|
|
class GenericsError {
|
|
private static class ListHolder<T> {
|
|
private List<T> <warning descr="Private field 'list' is never assigned">list</warning>;
|
|
|
|
private void <warning descr="Private method 'forEach(GenericsError.Looper<? super T>)' is never used">forEach</warning>(final Looper<? super T> looper) {
|
|
for (final T item : list) {
|
|
looper.loopItem(item);
|
|
}
|
|
}
|
|
|
|
|
|
private void forEach(final DeletingLooper<? super T> looper) {
|
|
for (final T item : list) {
|
|
looper.loopItem(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
private interface Looper<T> {
|
|
void loopItem(final T a);
|
|
}
|
|
|
|
private interface DeletingLooper<T> extends Looper<T> {
|
|
}
|
|
|
|
private static class MyDeletingLooper implements DeletingLooper<B> {
|
|
@Override
|
|
public void loopItem(final B a) {
|
|
}
|
|
}
|
|
|
|
private class A {
|
|
}
|
|
|
|
private class B extends A {
|
|
}
|
|
|
|
|
|
public static void main() {
|
|
final ListHolder<? extends B> aListHolder = new ListHolder<B>();
|
|
final DeletingLooper<? super B> bLooper = new MyDeletingLooper();
|
|
|
|
aListHolder.forEach(bLooper);
|
|
}
|
|
} |