View | Details | Raw Unified | Return to bug 231293 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/builder/Java50Tests.java (+57 lines)
Lines 108-113 Link Here
108
		expectingNoProblems();
108
		expectingNoProblems();
109
	}
109
	}
110
110
111
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=231293
112
	public void testMissingRequiredBinaries() throws JavaModelException {
113
		
114
		IPath p1 = env.addProject("P1", "1.5"); //$NON-NLS-1$
115
		IPath p2 = env.addProject("P2"); //$NON-NLS-1$
116
117
		env.addExternalJars(p1, Util.getJavaClassLibs());
118
		// remove old package fragment root so that names don't collide
119
		env.removePackageFragmentRoot(p1, ""); //$NON-NLS-1$
120
		IPath root1 = env.addPackageFragmentRoot(p1, "src"); //$NON-NLS-1$
121
		env.setOutputFolder(p1, "bin"); //$NON-NLS-1$
122
123
		env.addExternalJars(p2, Util.getJavaClassLibs());
124
		// remove old package fragment root so that names don't collide
125
		env.removePackageFragmentRoot(p2, ""); //$NON-NLS-1$
126
		IPath root2 = env.addPackageFragmentRoot(p2, "src"); //$NON-NLS-1$
127
		IPath p2bin = env.setOutputFolder(p2, "bin"); //$NON-NLS-1$
128
129
		env.addClass(root2, "p2", "Y", //$NON-NLS-1$ //$NON-NLS-2$
130
			"package p2;\n"+ //$NON-NLS-1$
131
			"public class Y {\n"+ //$NON-NLS-1$
132
			"	public void foo(int i) {}\n"+ //$NON-NLS-1$
133
			"	public void foo(int i, Z z) {}\n"+ //$NON-NLS-1$
134
			"}\n"+ //$NON-NLS-1$
135
			"class Z {}" //$NON-NLS-1$
136
			);
137
138
		fullBuild();
139
		expectingNoProblems();
140
141
		env.addClassFolder(p1, p2bin, false);
142
		env.removeFile(p2bin.append("p2/Z.class")); //$NON-NLS-1$
143
144
		env.addClass(root1, "p1", "X", //$NON-NLS-1$ //$NON-NLS-2$
145
			"package p1;\n"+ //$NON-NLS-1$
146
			"public class X {\n"+ //$NON-NLS-1$
147
			"	void test(p2.Y y) { y.foo(1); }\n"+ //$NON-NLS-1$
148
			"}\n" //$NON-NLS-1$
149
			);
150
151
		incrementalBuild(p1);
152
		expectingNoProblems();
153
154
		IPath xx = env.addClass(root1, "p1", "XX", //$NON-NLS-1$ //$NON-NLS-2$
155
			"package p1;\n"+ //$NON-NLS-1$
156
			"public class XX {\n"+ //$NON-NLS-1$
157
			"	void test(p2.Y y) { y.foo('c'); }\n"+ //$NON-NLS-1$
158
			"}\n" //$NON-NLS-1$
159
			);
160
161
		incrementalBuild(p1);
162
		expectingOnlySpecificProblemsFor(p1,new Problem[]{
163
				new Problem("p1", "The project was not built since its build path is incomplete. Cannot find the class file for p2.Z. Fix the build path then try building this project", p1, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR),//$NON-NLS-1$ //$NON-NLS-2$
164
				new Problem("p1", "The type p2.Z cannot be resolved. It is indirectly referenced from required .class files", xx, 51, 61, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)//$NON-NLS-1$ //$NON-NLS-2$
165
			});
166
	}
167
111
	public void testParameterizedMemberType() throws JavaModelException {
168
	public void testParameterizedMemberType() throws JavaModelException {
112
		IPath projectPath = env.addProject("Project", "1.5"); 
169
		IPath projectPath = env.addProject("Project", "1.5"); 
113
		env.addExternalJars(projectPath, Util.getJavaClassLibs());
170
		env.addExternalJars(projectPath, Util.getJavaClassLibs());
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-13 / +2 lines)
Lines 766-788 Link Here
766
766
767
	// Internal use only
767
	// Internal use only
768
	public MethodBinding findExactMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
768
	public MethodBinding findExactMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
769
		boolean checkArgsForRawTypes = false;
770
		// in 1.5 mode or higher, we're expecting that an exact match with more than 2 args is not that common
771
		// so save some time by not calling findExactMatch & use that time to handle the more common cases with 1 or 2 args.
772
		switch (argumentTypes.length) {
773
			case 0 : break;
774
			case 1 :
775
			case 2 :
776
				checkArgsForRawTypes = compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5;
777
			default :
778
				if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5)
779
					return null; // skip find exact match since its less likely to find a match & raw type check is not worth it
780
		}
781
		CompilationUnitScope unitScope = compilationUnitScope();
769
		CompilationUnitScope unitScope = compilationUnitScope();
782
		unitScope.recordTypeReferences(argumentTypes);
770
		unitScope.recordTypeReferences(argumentTypes);
783
		MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes, unitScope);
771
		MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes, unitScope);
784
		if (exactMethod != null && exactMethod.typeVariables == Binding.NO_TYPE_VARIABLES && !exactMethod.isBridge()) {
772
		if (exactMethod != null && exactMethod.typeVariables == Binding.NO_TYPE_VARIABLES && !exactMethod.isBridge()) {
785
			if (checkArgsForRawTypes)
773
			// in >= 1.5 mode, ensure the exactMatch did not match raw types
774
			if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5)
786
				for (int i = argumentTypes.length; --i >= 0;)
775
				for (int i = argumentTypes.length; --i >= 0;)
787
					if (argumentTypes[i].isRawType())
776
					if (argumentTypes[i].isRawType())
788
						return null;
777
						return null;

Return to bug 231293