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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java (-2 / +32 lines)
Lines 1557-1563 Link Here
1557
}
1557
}
1558
1558
1559
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=163370
1559
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=163370
1560
public void _test044() {
1560
public void test044() {
1561
	this.runConformTest(
1561
	this.runConformTest(
1562
		new String[] {
1562
		new String[] {
1563
			"X.java",
1563
			"X.java",
Lines 1580-1586 Link Here
1580
}
1580
}
1581
1581
1582
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165620
1582
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165620
1583
public void _test045() {
1583
public void test045() {
1584
	this.runConformTest(
1584
	this.runConformTest(
1585
		new String[] {
1585
		new String[] {
1586
			"X.java",
1586
			"X.java",
Lines 1607-1610 Link Here
1607
		},
1607
		},
1608
		"");
1608
		"");
1609
}
1609
}
1610
1611
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=163370
1612
// variant
1613
public void test046() {
1614
	this.runConformTest(
1615
		new String[] {
1616
			"X.java",
1617
			"abstract class Y<T, U> implements I<T, U> {\n" + 
1618
			"}\n" + 
1619
			"interface I<T, U> { \n" + 
1620
			"}\n" + 
1621
			"interface J<T, U> {\n" + 
1622
			"}\n" + 
1623
			"class X {\n" + 
1624
			"  public static <V extends J<V, W>, W extends J<V, W>> V foo(final I<V, W> a)\n" + 
1625
			"  {\n" + 
1626
			"    return null;\n" + 
1627
			"  }\n" + 
1628
			"  public static <V extends J<V, W>, W extends J<V, W>> V foo(final Y<V, W> a)\n" + 
1629
			"  {\n" + 
1630
			"    return null;\n" + 
1631
			"  }\n" + 
1632
			"  public static <V extends J<V, W>, W extends J<V, W>> void test(final Y<V, W> a)\n" + 
1633
			"  {\n" + 
1634
			"    foo(a);\n" + 
1635
			"  }\n" + 
1636
			"}"
1637
		},
1638
		"");
1639
}
1610
}
1640
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java (+25 lines)
Lines 1058-1061 Link Here
1058
		} 
1058
		} 
1059
		return Binding.NO_TYPE_VARIABLES;
1059
		return Binding.NO_TYPE_VARIABLES;
1060
	}	
1060
	}	
1061
1062
boolean uses(TypeVariableBinding variable) {
1063
	int argsNb = this.arguments.length;
1064
	for (int i = 0; i < argsNb; i++) {
1065
		if (this.arguments[i] == variable || this.arguments[i].uses(variable)) {
1066
			return true;
1067
		}
1068
	}
1069
	return false;
1070
}
1071
TypeBinding clearedOf(TypeVariableBinding variable) {
1072
	if (uses(variable)) {
1073
		int argsNb;
1074
		TypeBinding[] newArguments = new TypeBinding[argsNb = this.arguments.length];
1075
		for (int i = 0; i < argsNb; i++) {
1076
			if (this.arguments[i].uses(variable)) {
1077
				return new RawTypeBinding(this.type, this.enclosingType, this.environment);
1078
			}
1079
			newArguments[i] = this.arguments[i].clearedOf(variable);
1080
		}
1081
		return new ParameterizedTypeBinding(this.type, newArguments, 
1082
				this.enclosingType, this.environment);
1083
	}
1084
	return this;
1085
}
1061
}
1086
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java (+21 lines)
Lines 963-966 Link Here
963
public TypeVariableBinding[] typeVariables() {
963
public TypeVariableBinding[] typeVariables() {
964
	return Binding.NO_TYPE_VARIABLES;
964
	return Binding.NO_TYPE_VARIABLES;
965
}
965
}
966
967
/**
968
 * Return true iff variable participates to the definition of this, directly or
969
 * indirectly (through type parameters, bounds, etc.). Type variables are 
970
 * matched by names, not by identity.
971
 * @param variable the type variable to search for
972
 * @return true iff variable participates to the definition of this
973
 */
974
boolean uses(TypeVariableBinding variable) {
975
	return false;
976
}
977
/**
978
 * Return this if variable does not participate to its definition, a new type
979
 * binding that contains rawified types instead of parameterized types that
980
 * use variable else.
981
 * @param variable the type variable to eliminate
982
 * @return a type binding that does not use variable
983
 */
984
TypeBinding clearedOf(TypeVariableBinding variable) {
985
	return this;
986
}
966
}
987
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java (-3 / +4 lines)
Lines 460-471 Link Here
460
			TypeBinding[] newArguments = new TypeBinding[length];
460
			TypeBinding[] newArguments = new TypeBinding[length];
461
			boolean isStatic = this.isStatic();
461
			boolean isStatic = this.isStatic();
462
			for (int i = 0; i < length; i++) {
462
			for (int i = 0; i < length; i++) {
463
				newArguments[i] = isStatic ? 
463
				newArguments[i] = isStatic ?
464
					originalVariables[i].upperBound() : // do not rawify for statics
464
					originalVariables[i].semiRawifiedFirstUpperBound() :
465
						// full rawification too much for statics
465
					environment.convertToRawType(originalVariables[i].upperBound());
466
					environment.convertToRawType(originalVariables[i].upperBound());
466
			}
467
			}
467
			this.tiebreakMethod = this.environment.createParameterizedGenericMethod(this.originalMethod, newArguments);
468
			this.tiebreakMethod = this.environment.createParameterizedGenericMethod(this.originalMethod, newArguments);
468
		} 
469
		} 
469
		return this.tiebreakMethod;
470
		return this.tiebreakMethod;
470
	}	
471
	}
471
}
472
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java (-1 / +27 lines)
Lines 440-444 Link Here
440
			return this.firstBound;
440
			return this.firstBound;
441
	    }
441
	    }
442
	    return this.superclass; // java/lang/Object
442
	    return this.superclass; // java/lang/Object
443
	}		
443
	}
444
	
445
/**
446
 * Return the first upper bound of this if it does not reference this, else 
447
 * elaborate and return a copy of the first upper bound of this where raw types 
448
 * replace parameterized types that reference this. The type variables matching 
449
 * relies on names. Examples (in which this is named T):
450
 * <pre>
451
 * T -&gt>; /java/lang/Object
452
 * T extends X&amp;I -&gt; X
453
 * T extends X&lt;String&gt; -&gt; X&lt;String&gt;
454
 * T extends X&lt;T&gt; -&gt; X#RAW
455
 * </pre>
456
 * The result has the property of not relying upon recursion for its definition.
457
 * @return the first upper bound of this if it does not reference this, a 
458
 *         modified copy of the first upper bound of this else
459
 */
460
TypeBinding semiRawifiedFirstUpperBound() {
461
	if (this.firstBound == null) {
462
		return this.superclass; // java/lang/Object
463
	} 
464
	return this.firstBound.clearedOf(this); 
465
}
466
467
boolean uses(TypeVariableBinding variable) {
468
	return CharOperation.equals(variable.sourceName, this.sourceName);
469
}
444
}
470
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java (+7 lines)
Lines 624-627 Link Here
624
		}
624
		}
625
		return this.typeVariable;
625
		return this.typeVariable;
626
	}
626
	}
627
628
boolean uses(TypeVariableBinding variable) {
629
	if (this.bound != null) {
630
		return this.bound.uses(variable);
631
	}
632
	return false;
633
}
627
}
634
}

Return to bug 163370