View | Details | Raw Unified | Return to bug 251690
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (-1 / +2 lines)
Lines 84-90 Link Here
84
		}
84
		}
85
	} else {
85
	} else {
86
		if ((this.fPackage = this.environment.createPackage(this.currentPackageName)) == null) {
86
		if ((this.fPackage = this.environment.createPackage(this.currentPackageName)) == null) {
87
			problemReporter().packageCollidesWithType(this.referenceContext);
87
			if (this.referenceContext.currentPackage != null)
88
				problemReporter().packageCollidesWithType(this.referenceContext); // only report when the unit has a package statement
88
			return;
89
			return;
89
		} else if (this.referenceContext.isPackageInfo()) {
90
		} else if (this.referenceContext.isPackageInfo()) {
90
			// resolve package annotations now if this is "package-info.java".
91
			// resolve package annotations now if this is "package-info.java".
(-)src/org/eclipse/jdt/core/tests/builder/PackageTests.java (+28 lines)
Lines 15-24 Link Here
15
import junit.framework.*;
15
import junit.framework.*;
16
16
17
import org.eclipse.core.resources.IFolder;
17
import org.eclipse.core.resources.IFolder;
18
import org.eclipse.core.resources.IMarker;
18
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.jdt.core.JavaModelException;
22
import org.eclipse.jdt.core.JavaModelException;
23
import org.eclipse.jdt.core.compiler.CategorizedProblem;
22
import org.eclipse.jdt.core.tests.util.Util;
24
import org.eclipse.jdt.core.tests.util.Util;
23
25
24
public class PackageTests extends BuilderTests {
26
public class PackageTests extends BuilderTests {
Lines 83-88 Link Here
83
		expectingNoProblems();
85
		expectingNoProblems();
84
	}
86
	}
85
87
88
	/**
89
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=251690
90
	 */
91
	public void testNoPackageProblem() throws JavaModelException {
92
		IPath projectPath = env.addProject("Project"); //$NON-NLS-1$
93
		env.addExternalJars(projectPath, Util.getJavaClassLibs());
94
		env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$
95
		IPath src = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$
96
		env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$
97
98
		IPath aPath = env.addClass(src, "p", "A", //$NON-NLS-1$ //$NON-NLS-2$
99
			"package p;\n"+ //$NON-NLS-1$
100
			"public class A {}" //$NON-NLS-1$
101
		);
102
103
		IPath bPath = env.addClass(src, "p.A", "B", //$NON-NLS-1$ //$NON-NLS-2$
104
			"public class B {}" //$NON-NLS-1$
105
		);
106
107
		fullBuild();
108
		expectingOnlySpecificProblemFor(aPath,
109
			new Problem("", "The type A collides with a package", aPath, 24, 25, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_WARNING)); //$NON-NLS-1$ //$NON-NLS-2$
110
		expectingOnlySpecificProblemFor(bPath,
111
			new Problem("", "The declared package \"\" does not match the expected package \"p.A\"", bPath, 0, 0, CategorizedProblem.CAT_INTERNAL, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
112
	}
113
86
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=117092
114
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=117092
87
// simplistic linked subfolder used as package, external case (not in workspace)
115
// simplistic linked subfolder used as package, external case (not in workspace)
88
public void test001() throws CoreException {
116
public void test001() throws CoreException {

Return to bug 251690