From b6860a09ac61351d5b830916c1fa2d1c20a5e971 Mon Sep 17 00:00:00 2001 From: Stephan Herrmann Date: Sun, 15 Dec 2024 22:59:37 +0100 Subject: [PATCH] [24] don't request access to enclosing class if it's never used + additional test Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3194 --- .../regression/SuperAfterStatementsTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuperAfterStatementsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuperAfterStatementsTest.java index 970a370daab..402ac2b8e3c 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuperAfterStatementsTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuperAfterStatementsTest.java @@ -2509,4 +2509,30 @@ public static void main(String... args0) { """}, ""); } + + public void testGH3194_reopen() { + runConformTest(new String[] { + "X.java", + """ + sealed interface A permits X {} + public final class X implements A { + int a = 1; + class One { + int b = 2; + class Two { + int c = 3; + class Three { + int r = a + b + c; + } + } + } + public static void main(String argv[]) { + X x = new X(); + One.Two.Three ci = x.new One().new Two().new Three(); // No enclosing instance of type X is accessible. Must qualify the allocation... + System.out.println(ci.r); + } + } + """ + }); + } }