Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatterns/InstanceOfNonReified.java
Tagir Valeev e43800cb62 IDEA-230729 Good code red: Illegal generic type for instanceof
GitOrigin-RevId: 03fa8e1c2e663e50bd0968423fe07a9a7e05a0d1
2020-01-24 08:03:38 +00:00

22 lines
744 B
Java

import java.util.ArrayList;
import java.util.List;
interface Iface {}
class Cls implements Iface {}
class Foo<T> {}
class InstanceOfNonReified {
void test(List<Cls> o) {
boolean b1 = o instanceof ArrayList<Cls>;
boolean b2 = <error descr="Inconvertible types; cannot cast 'java.util.List<Cls>' to 'java.util.ArrayList<Iface>'">o instanceof ArrayList<Iface></error>;
boolean b3 = o instanceof <error descr="'List<Cls>' cannot be safely cast to 'Foo<Cls>'">Foo<Cls></error>;
}
public static void main(String [] args) {
Object o = new ArrayList<Object>();
if (o instanceof <error descr="'Object' cannot be safely cast to 'ArrayList<Integer>'">ArrayList<Integer></error> ai) {
System.out.println("");
}
}
}