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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java (+4 lines)
Lines 498-506 Link Here
498
	int[] toSkip = null;
498
	int[] toSkip = null;
499
	if (iMethods != null) {
499
	if (iMethods != null) {
500
		total = initialTotal = iMethods.length;
500
		total = initialTotal = iMethods.length;
501
		boolean keepBridgeMethods = sourceLevel < ClassFileConstants.JDK1_5
502
			&& this.environment.globalOptions.complianceLevel >= ClassFileConstants.JDK1_5;
501
		for (int i = total; --i >= 0;) {
503
		for (int i = total; --i >= 0;) {
502
			IBinaryMethod method = iMethods[i];
504
			IBinaryMethod method = iMethods[i];
503
			if ((method.getModifiers() & ClassFileConstants.AccSynthetic) != 0) {
505
			if ((method.getModifiers() & ClassFileConstants.AccSynthetic) != 0) {
506
				if (keepBridgeMethods && (method.getModifiers() & ClassFileConstants.AccBridge) != 0)
507
					continue; // want to see bridge methods as real methods
504
				// discard synthetics methods
508
				// discard synthetics methods
505
				if (toSkip == null) toSkip = new int[iMethods.length];
509
				if (toSkip == null) toSkip = new int[iMethods.length];
506
				toSkip[i] = -1;
510
				toSkip[i] = -1;
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-1 / +8 lines)
Lines 759-766 Link Here
759
		CompilationUnitScope unitScope = compilationUnitScope();
759
		CompilationUnitScope unitScope = compilationUnitScope();
760
		unitScope.recordTypeReferences(argumentTypes);
760
		unitScope.recordTypeReferences(argumentTypes);
761
		MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes, unitScope);
761
		MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes, unitScope);
762
		if (exactMethod != null && exactMethod.typeVariables == Binding.NO_TYPE_VARIABLES) {
762
		if (exactMethod != null && exactMethod.typeVariables == Binding.NO_TYPE_VARIABLES && !exactMethod.isBridge()) {
763
			// must find both methods for this case: <S extends A> void foo() {}  and  <N extends B> N foo() { return null; }
763
			// must find both methods for this case: <S extends A> void foo() {}  and  <N extends B> N foo() { return null; }
764
			// or find an inherited method when the exact match is to a bridge method
764
			unitScope.recordTypeReferences(exactMethod.thrownExceptions);
765
			unitScope.recordTypeReferences(exactMethod.thrownExceptions);
765
			// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
766
			// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
766
			if (receiverType.isInterface() || exactMethod.canBeSeenBy(receiverType, invocationSite, this)) {
767
			if (receiverType.isInterface() || exactMethod.canBeSeenBy(receiverType, invocationSite, this)) {
Lines 1086-1091 Link Here
1086
										continue nextMethod; // keep inherited substituted methods to detect anonymous errors
1087
										continue nextMethod; // keep inherited substituted methods to detect anonymous errors
1087
									if (matchingMethod.hasSubstitutedParameters() && !currentMethod.original().areParametersEqual(matchingMethod.original()))
1088
									if (matchingMethod.hasSubstitutedParameters() && !currentMethod.original().areParametersEqual(matchingMethod.original()))
1088
										continue nextMethod; // keep inherited substituted methods to detect anonymous errors
1089
										continue nextMethod; // keep inherited substituted methods to detect anonymous errors
1090
									if (matchingMethod.isBridge() && !currentMethod.isBridge())
1091
										continue nextMethod; // keep inherited methods to find concrete method over a bridge method
1089
								}
1092
								}
1090
								currentLength--;
1093
								currentLength--;
1091
								currentMethods[i] = null;
1094
								currentMethods[i] = null;
Lines 3226-3231 Link Here
3226
						continue nextVisible;
3229
						continue nextVisible;
3227
					if (!isAcceptableMethod(tiebreakMethod, acceptable))
3230
					if (!isAcceptableMethod(tiebreakMethod, acceptable))
3228
						continue nextVisible;
3231
						continue nextVisible;
3232
					// pick a concrete method over a bridge method when parameters are equal since the return type of the concrete method is more specific
3233
					if (current.isBridge() && !next.isBridge())
3234
						if (tiebreakMethod.areParametersEqual(acceptable))
3235
							continue nextVisible; // skip current so acceptable wins over this bridge method
3229
				}
3236
				}
3230
				moreSpecific[i] = current;
3237
				moreSpecific[i] = current;
3231
				count++;
3238
				count++;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java (+53 lines)
Lines 2325-2330 Link Here
2325
			options,
2325
			options,
2326
			null);
2326
			null);
2327
}
2327
}
2328
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=139099
2329
public void test068a() {
2330
	Map options = this.getCompilerOptions();
2331
	CompilerOptions compOptions = new CompilerOptions(options);
2332
	if (compOptions.complianceLevel < ClassFileConstants.JDK1_5) return;
2333
2334
	this.runConformTest(
2335
		new String[] {
2336
			"X1.java",
2337
			"public class X1 { X1 foo() { return null; } }\n" + 
2338
			"class X2 extends X1 { X2 foo() { return null; } }\n" + 
2339
			"class Y { public X2 foo() { return null; } }\n" + 
2340
			"interface I { X1 foo(); }\n" + 
2341
			"class Z extends Y implements I {}",
2342
		},
2343
		"");
2344
	this.runConformTest(
2345
		new String[] {
2346
			"Test.java",//===================
2347
			"public class Test {\n" + 
2348
			"    public static void main(String[] args) {\n" + 
2349
			"        X1 x = new X2().foo();\n" + 
2350
			"        X2 xx = new X2().foo();\n" + 
2351
			"        X1 z = new Z().foo();\n" + 
2352
			"        X2 zz = new Z().foo();\n" + 
2353
			"    }\n" + 
2354
			"}", // =================,
2355
		},
2356
		"",
2357
		null,
2358
		false,
2359
		null);
2360
2361
	options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);
2362
	this.runConformTest(
2363
		new String[] {
2364
			"Test14.java",//===================
2365
			"public class Test14 {\n" + 
2366
			"    public static void main(String[] args) {\n" + 
2367
			"        X1 x = new X2().foo();\n" + 
2368
			"        X2 xx = new X2().foo();\n" + 
2369
			"        X1 z = new Z().foo();\n" + 
2370
			"        X2 zz = new Z().foo();\n" + 
2371
			"    }\n" + 
2372
			"}", // =================,
2373
		},
2374
		"",
2375
		null,
2376
		false,
2377
		null,
2378
		options,
2379
		null);
2380
}
2328
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=139099 - variation
2381
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=139099 - variation
2329
public void test069() {
2382
public void test069() {
2330
	this.runConformTest(
2383
	this.runConformTest(

Return to bug 153874