diff options
author | Till Brychcy | 2019-08-11 09:19:12 +0000 |
---|---|---|
committer | Till Brychcy | 2019-08-11 09:34:24 +0000 |
commit | c19c6a4f496a82dc889f7978fc504c559cb52dec (patch) | |
tree | b34221193f5b84c84f5ad3e95d15ed115c104032 | |
parent | 2d0ebadd6a1900252e5b1e8c558df1c9fda958c6 (diff) | |
download | eclipse.jdt.core-c19c6a4f496a82dc889f7978fc504c559cb52dec.tar.gz eclipse.jdt.core-c19c6a4f496a82dc889f7978fc504c559cb52dec.tar.xz eclipse.jdt.core-c19c6a4f496a82dc889f7978fc504c559cb52dec.zip |
Bug 549942 - Impossible to compile CDT 2019-09 using Eclipse 2019-09 M2I20190811-1800
with JDT 3.18.100.v20190801-0600
Change-Id: Ibbcca89680db3aef1d588575fe1ff6ed06a664be
2 files changed, 63 insertions, 13 deletions
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java index 89cb541d62..6c170df892 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java @@ -331,7 +331,7 @@ public class BasicBuildTests extends BuilderTests { "public class MyException extends Exception {\n" + " private static final long serialVersionUID = 1L;\n" + "}" - ); //$NON-NLS-1$ + ); env.addClass(root, "p", "Test", //$NON-NLS-1$ //$NON-NLS-2$ "package p;\n" + @@ -410,7 +410,7 @@ public class BasicBuildTests extends BuilderTests { "public class MyException extends Exception {\n" + " private static final long serialVersionUID = 1L;\n" + "}" - ); //$NON-NLS-1$ + ); IPath cuPath = env.addClass(root, "p", "Test", //$NON-NLS-1$ //$NON-NLS-2$ "package p;\n" + @@ -445,7 +445,7 @@ public class BasicBuildTests extends BuilderTests { "public class MyException extends Exception {\n" + " private static final long serialVersionUID = 1L;\n" + "}" - ); //$NON-NLS-1$ + ); IPath cuPath = env.addClass(root, "p", "Test", //$NON-NLS-1$ //$NON-NLS-2$ "package p;\n" + @@ -531,33 +531,33 @@ public class BasicBuildTests extends BuilderTests { try { IPath projectPath = env.addProject("Project"); env.addExternalJars(projectPath, Util.getJavaClassLibs()); - + // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath, ""); - + IPath root = env.addPackageFragmentRoot(projectPath, "src"); env.setOutputFolder(projectPath, "bin"); - + // this class is the primary unit during build (see comment below) env.addClass(root, "pack", "Zork", "package pack;\npublic class Zork { Main main; }\n" // pull in Main first ); - + env.addClass(root, "pack", "Main", "package pack;\n" + "public class Main {\n" + " Main$Sub sub;\n" + // indirectly pull in Main$Sub "}\n" ); - + env.addClass(root, "pack", "Main$Sub", "package pack;\n" + "public class Main$Sub { }\n" ); - + org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = 1; - + // Assumption regarding the order of compilation units: // - org.eclipse.core.internal.dtree.AbstractDataTreeNode.assembleWith(AbstractDataTreeNode[], AbstractDataTreeNode[], boolean) // assembles children array in lexical order, so "Zork.java" is last @@ -568,7 +568,7 @@ public class BasicBuildTests extends BuilderTests { // puts only "Zork.java" into 'toCompile' (due to MAX_AT_ONCE=1) and the others into 'remainingUnits' // This ensures that NameEnvironment is setup with "Main.java" and "Main$Sub.java" both served from 'additionalUnits' // which is essential for reproducing the bug. - + fullBuild(projectPath); expectingNoProblems(); } finally { @@ -577,7 +577,7 @@ public class BasicBuildTests extends BuilderTests { } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=386901 public void testbBug386901() throws JavaModelException { - + int previous = org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE; try { IPath projectPath = env.addProject("Project"); //$NON-NLS-1$ @@ -637,4 +637,54 @@ public class BasicBuildTests extends BuilderTests { "Problem : The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files [ resource : </Project/src/X.java> range : <0,1> category : <10> severity : <2>]" ); } + public void testBug549942() throws JavaModelException { + int save = org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE; + try { + IPath projectPath = env.addProject("Project"); + env.addExternalJars(projectPath, Util.getJavaClassLibs()); + + // remove old package fragment root so that names don't collide + env.removePackageFragmentRoot(projectPath, ""); + + IPath root = env.addPackageFragmentRoot(projectPath, "src"); + env.setOutputFolder(projectPath, "bin"); + + env.addClass(root, "test", + "ARequiresNested", + "package test;\n" + + "\n" + + "public class ARequiresNested {\n" + + " Nested n;\n" + + "}" + ); + + env.addClass(root, "test", + "BRequiresToplevel", + "package test;\n" + + "\n" + + "public class BRequiresToplevel {\n" + + " TopLevel t;\n" + + "}" + ); + + env.addClass(root, "test", + "TopLevel", + "package test;\n" + + "\n" + + "public class TopLevel {\n" + + "\n" + + "}\n" + + "\n" + + "class Nested extends TopLevel {\n" + + "}" + ); + + org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = 2; + + fullBuild(projectPath); + expectingNoProblems(); + } finally { + org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = save; + } + } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java index 506564509a..282e542ab4 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java @@ -231,7 +231,7 @@ ReferenceBinding getType0(char[] name) { */ boolean hasType0Any(char[] name) { ReferenceBinding type0 = getType0(name); - return type0 != null && type0 != LookupEnvironment.TheNotFoundType && !(type0 instanceof UnresolvedReferenceBinding); + return type0 != null && type0.isValidBinding() && !(type0 instanceof UnresolvedReferenceBinding); } /* Answer the package or type named name; ask the oracle if it is not in the cache. |