From 6e8ed8e0dc677bb423866b5d041345d6837bc205 Mon Sep 17 00:00:00 2001 From: Suzanne Millstein Date: Fri, 11 Oct 2024 11:03:35 -0700 Subject: [PATCH] Skip parens --- framework/tests/all-systems/Issue6856.java | 7 +++++++ .../java/org/checkerframework/javacutil/TreeUtils.java | 1 + 2 files changed, 8 insertions(+) create mode 100644 framework/tests/all-systems/Issue6856.java diff --git a/framework/tests/all-systems/Issue6856.java b/framework/tests/all-systems/Issue6856.java new file mode 100644 index 00000000000..4d68fe83364 --- /dev/null +++ b/framework/tests/all-systems/Issue6856.java @@ -0,0 +1,7 @@ +import java.util.Collections; + +public class Issue6856 { + static void test(Class p) { + var x = Collections.checkedCollection((Collections.emptyList()), p); + } +} diff --git a/javacutil/src/main/java/org/checkerframework/javacutil/TreeUtils.java b/javacutil/src/main/java/org/checkerframework/javacutil/TreeUtils.java index 93dc1ae9041..3bf5d053d36 100644 --- a/javacutil/src/main/java/org/checkerframework/javacutil/TreeUtils.java +++ b/javacutil/src/main/java/org/checkerframework/javacutil/TreeUtils.java @@ -2849,6 +2849,7 @@ public static boolean isPolyExpression(ExpressionTree expression) { * @return whether or not {@code expression} is a standalone expression */ public static boolean isStandaloneExpression(ExpressionTree expression) { + expression = TreeUtils.withoutParens(expression); if (expression instanceof JCTree.JCExpression) { if (((JCTree.JCExpression) expression).isStandalone()) { return true;