From 0572ae906e02951af7ea4ff650030ac8a4e67b2d Mon Sep 17 00:00:00 2001 From: "Ahmad K. Bawaneh" Date: Thu, 8 Aug 2024 17:35:40 +0300 Subject: [PATCH 1/3] Add test for negative instanceof variable outside if scope --- .../jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java b/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java index a15c35acf6..3385ed0575 100644 --- a/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java +++ b/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java @@ -379,4 +379,12 @@ public void testInstanceOfPatternMatchingAsReturn() { Bar bar = new Bar(); assertTrue(bar.isSquare()); } + + public void testNegativeInstanceOfPatternOutsideIfScope() { + Object bar = new Bar(); + if(!(bar instanceof Bar b)) { + throw new RuntimeException(); + } + assertTrue(b.isSquare()); + } } From 9f75db05d7f8ba3367ce4b5684df644fc5e6d632 Mon Sep 17 00:00:00 2001 From: "Ahmad K. Bawaneh" Date: Sun, 11 Aug 2024 17:08:00 +0300 Subject: [PATCH 2/3] add tests to the super source tests --- .../com/google/gwt/dev/jjs/test/Java17Test.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/user/test/com/google/gwt/dev/jjs/test/Java17Test.java b/user/test/com/google/gwt/dev/jjs/test/Java17Test.java index f14ad1f227..ea0162a6ae 100644 --- a/user/test/com/google/gwt/dev/jjs/test/Java17Test.java +++ b/user/test/com/google/gwt/dev/jjs/test/Java17Test.java @@ -62,6 +62,10 @@ public void testInstanceOfPatternMatching() { assertFalse(isGwtSourceLevel17()); } + public void testInstanceOfPatternMatchingWithSideEffectExpression() { + assertFalse(isGwtSourceLevel17()); + } + public void testInstanceOfPatternMatchingWithAnd() { assertFalse(isGwtSourceLevel17()); } @@ -78,6 +82,14 @@ public void testMultipleInstanceOfPatternMatchingWithSameVariableName() { assertFalse(isGwtSourceLevel17()); } + public void testMultipleInstanceOfPatternMatchingWithSameVariableNameWithDifferentTypes() { + assertFalse(isGwtSourceLevel17()); + } + + public void testInstanceOfPatternMatchingIsFalse() { + assertFalse(isGwtSourceLevel17()); + } + public void testInstanceOfPatternMatchingInLambda() { assertFalse(isGwtSourceLevel17()); } @@ -86,6 +98,10 @@ public void testInstanceOfPatternMatchingAsReturn() { assertFalse(isGwtSourceLevel17()); } + public void testNegativeInstanceOfPatternOutsideIfScope() { + assertFalse(isGwtSourceLevel17()); + } + private boolean isGwtSourceLevel17() { return JUnitShell.getCompilerOptions().getSourceLevel().compareTo(SourceLevel.JAVA17) >= 0; } From 7f25fa6655f0e758fbdc5adedfe8a5d8e6ae3465 Mon Sep 17 00:00:00 2001 From: "Ahmad K. Bawaneh" Date: Sat, 10 Aug 2024 16:39:48 +0300 Subject: [PATCH 3/3] Update user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java Co-authored-by: Zbynek Konecny --- .../dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java b/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java index 3385ed0575..52b37a4786 100644 --- a/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java +++ b/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java @@ -382,7 +382,7 @@ public void testInstanceOfPatternMatchingAsReturn() { public void testNegativeInstanceOfPatternOutsideIfScope() { Object bar = new Bar(); - if(!(bar instanceof Bar b)) { + if (!(bar instanceof Bar b)) { throw new RuntimeException(); } assertTrue(b.isSquare());