diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/IfPatternMatchProcessor.java b/src/org/jetbrains/java/decompiler/modules/decompiler/IfPatternMatchProcessor.java index 471dccb10e..1ff0e161d0 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/IfPatternMatchProcessor.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/IfPatternMatchProcessor.java @@ -168,10 +168,15 @@ private static boolean checkBranch(Exprent exprent, IfStatement statement, State return false; } } + + VarType storeType = left.getInferredExprType(null); // Add the exprent to the instanceof exprent and remove it from the inside of the if statement iof.getLstOperands().add(2, left); head.getExprents().remove(0); + if (storeType.isGeneric()) { + iof.getLstOperands().set(1, new ConstExprent(storeType, null, iof.getLstOperands().get(1).bytecode)); + } statement.setPatternMatched(true); diff --git a/testData/results/pkg/TestSwitchPatternMatchingInstanceof4.dec b/testData/results/pkg/TestSwitchPatternMatchingInstanceof4.dec index 30e8fb48a8..529ece6b54 100644 --- a/testData/results/pkg/TestSwitchPatternMatchingInstanceof4.dec +++ b/testData/results/pkg/TestSwitchPatternMatchingInstanceof4.dec @@ -6,7 +6,7 @@ public class TestSwitchPatternMatchingInstanceof4 { public void test(Object o) { Objects.requireNonNull(o);// 5 switch (o) { - case String s when o instanceof Class clzz && clzz.getSigners()[0] instanceof Class c2:// 6 + case String s when o instanceof Class clzz && clzz.getSigners()[0] instanceof Class c2:// 6 System.out.println("" + clzz + c2); break; default: