From aab0b28c49a60db6f9575b2b1aad79843a31d5ee Mon Sep 17 00:00:00 2001 From: Srikanth Sankaran <131454720+srikanth-sankaran@users.noreply.github.com> Date: Wed, 14 Feb 2024 10:41:27 +0530 Subject: [PATCH] Regression test for snippet from #1804 that works fine now (#2014) --- .../regression/RecordPatternTest.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordPatternTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordPatternTest.java index c138ae59058..0af4ba1dbdc 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordPatternTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordPatternTest.java @@ -4096,4 +4096,37 @@ public static void main(String[] args) { + "110\n" + "220"); } + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1804 + // Revisit code generation for record patterns + public void testIssue1804() { + runConformTest( + new String[] { + "X.java", + """ + public class X { + record Paper(int color) {} + record Box(T a) {} + public static void main(String argv[]) { + foo(null, null); + } + public static void foo(String abc, String def) { + Box p = new Box<>(new Paper(0)); + boolean b = false; + switch (p) { + case Box(Paper a) -> { + b = true; + break; + } + default -> { + b = false; + break; + } + } + System.out.println(b); + } + } + """ + }, + "true"); + } }