diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java index c6f8afd210b..b0cd362779d 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java @@ -7867,13 +7867,13 @@ public void test0238() throws JavaModelException { * https://bugs.eclipse.org/bugs/show_bug.cgi?id=173338 */ public void test0238_2() throws JavaModelException { - this.workingCopy = getWorkingCopy("/Converter15/src/test0238/X.java", true/*resolve*/); - String contents = - "package test0238;\n" + - "public class X extends A {\n" + - "}"; + this.workingCopy = getWorkingCopy("/Converter15/src/test0238/X.java", + """ + package test0238; + public class X extends A { + }""", true/*resolve*/); ASTNode node = buildAST( - contents, + this.workingCopy.getSource(), this.workingCopy, false, false, diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java index 1988de8c26b..f65ed319058 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java @@ -1266,6 +1266,9 @@ private CompilationUnitDeclaration resolve( if (unit == null) { unit = this.unitsToProcess[0]; // fall back to old behavior } + if (this.totalUnits == 1 && this.lookupEnvironment.unitBeingCompleted == null) { + this.lookupEnvironment.unitBeingCompleted = unit; + } } else { // initial type binding creation this.lookupEnvironment.buildTypeBindings(unit, null /*no access restriction*/);