void () { myFixture.configureByText("Test.java", """ import java.io.Serializable; import java.util.List; import java.util.function.Supplier; record Box<T extends CharSequence>(T get) implements Supplier<T>, Serializable {} class ClassTest { <T extends Serializable & Supplier<String>> void typeArg(T t) { // TODO: wrong error; looks like a problem in isUncheckedCast, not inference-related if (t instanceof <error descr="'T' cannot be safely cast to 'Box<String>'">Box<String>(var v)</error>) { System.out.println(v.trim()); } if (t instanceof Box(var v)) { System.out.println(v.trim()); } } <T extends Serializable & Supplier<Integer>> void typeArgWrong(T t) { if (t instanceof <error descr="Cannot infer pattern type: no instance(s) of type variable(s) exist so that Integer conforms to CharSequence">Box</error>(var v)) { System.out.println(v.<error descr="Cannot resolve method 'intValue' in 'T'">intValue</error>()); System.out.println(v.chars()); System.out.println(v.<error descr="Cannot resolve method 'trim' in 'T'">trim</error>()); } } void intersection(Object obj) { var x = (Serializable & Supplier<String>) obj; if (x instanceof Box(var v)) { System.out.println(v.trim()); } var y = (Serializable & Supplier<Integer>) obj; if (y instanceof <error descr="Cannot infer pattern type: no instance(s) of type variable(s) exist so that Integer conforms to CharSequence">Box</error>(var v)) { System.out.println(v.<error descr="Cannot resolve method 'intValue' in 'T'">intValue</error>()); System.out.println(v.chars()); System.out.println(v.<error descr="Cannot resolve method 'trim' in 'T'">trim</error>()); } } } """); myFixture.checkHighlighting(); }