### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java,v retrieving revision 1.31 diff -u -r1.31 AmbiguousMethodTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 23 Nov 2006 14:53:12 -0000 1.31 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 24 Nov 2006 14:19:50 -0000 @@ -1557,7 +1557,7 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=163370 -public void _test044() { +public void test044() { this.runConformTest( new String[] { "X.java", @@ -1580,7 +1580,7 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165620 -public void _test045() { +public void test045() { this.runConformTest( new String[] { "X.java", @@ -1607,4 +1607,34 @@ }, ""); } + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=163370 +// variant +public void test046() { + this.runConformTest( + new String[] { + "X.java", + "abstract class Y implements I {\n" + + "}\n" + + "interface I { \n" + + "}\n" + + "interface J {\n" + + "}\n" + + "class X {\n" + + " public static , W extends J> V foo(final I a)\n" + + " {\n" + + " return null;\n" + + " }\n" + + " public static , W extends J> V foo(final Y a)\n" + + " {\n" + + " return null;\n" + + " }\n" + + " public static , W extends J> void test(final Y a)\n" + + " {\n" + + " foo(a);\n" + + " }\n" + + "}" + }, + ""); +} } #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java,v retrieving revision 1.86 diff -u -r1.86 ParameterizedTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 9 Oct 2006 11:21:52 -0000 1.86 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 24 Nov 2006 14:19:54 -0000 @@ -1058,4 +1058,29 @@ } return Binding.NO_TYPE_VARIABLES; } + +boolean uses(TypeVariableBinding variable) { + int argsNb = this.arguments.length; + for (int i = 0; i < argsNb; i++) { + if (this.arguments[i] == variable || this.arguments[i].uses(variable)) { + return true; + } + } + return false; +} +TypeBinding clearedOf(TypeVariableBinding variable) { + if (uses(variable)) { + int argsNb; + TypeBinding[] newArguments = new TypeBinding[argsNb = this.arguments.length]; + for (int i = 0; i < argsNb; i++) { + if (this.arguments[i].uses(variable)) { + return new RawTypeBinding(this.type, this.enclosingType, this.environment); + } + newArguments[i] = this.arguments[i].clearedOf(variable); + } + return new ParameterizedTypeBinding(this.type, newArguments, + this.enclosingType, this.environment); + } + return this; +} } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java,v retrieving revision 1.77 diff -u -r1.77 TypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 9 Nov 2006 14:21:27 -0000 1.77 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 24 Nov 2006 14:19:54 -0000 @@ -963,4 +963,25 @@ public TypeVariableBinding[] typeVariables() { return Binding.NO_TYPE_VARIABLES; } + +/** + * Return true iff variable participates to the definition of this, directly or + * indirectly (through type parameters, bounds, etc.). Type variables are + * matched by names, not by identity. + * @param variable the type variable to search for + * @return true iff variable participates to the definition of this + */ +boolean uses(TypeVariableBinding variable) { + return false; +} +/** + * Return this if variable does not participate to its definition, a new type + * binding that contains rawified types instead of parameterized types that + * use variable else. + * @param variable the type variable to eliminate + * @return a type binding that does not use variable + */ +TypeBinding clearedOf(TypeVariableBinding variable) { + return this; +} } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java,v retrieving revision 1.53 diff -u -r1.53 ParameterizedGenericMethodBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java 18 Oct 2006 13:25:23 -0000 1.53 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java 24 Nov 2006 14:19:53 -0000 @@ -460,12 +460,13 @@ TypeBinding[] newArguments = new TypeBinding[length]; boolean isStatic = this.isStatic(); for (int i = 0; i < length; i++) { - newArguments[i] = isStatic ? - originalVariables[i].upperBound() : // do not rawify for statics + newArguments[i] = isStatic ? + originalVariables[i].semiRawifiedFirstUpperBound() : + // full rawification too much for statics environment.convertToRawType(originalVariables[i].upperBound()); } this.tiebreakMethod = this.environment.createParameterizedGenericMethod(this.originalMethod, newArguments); } return this.tiebreakMethod; - } + } } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java,v retrieving revision 1.54 diff -u -r1.54 TypeVariableBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java 25 Jun 2006 21:33:33 -0000 1.54 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java 24 Nov 2006 14:19:55 -0000 @@ -440,5 +440,31 @@ return this.firstBound; } return this.superclass; // java/lang/Object - } + } + +/** + * Return the first upper bound of this if it does not reference this, else + * elaborate and return a copy of the first upper bound of this where raw types + * replace parameterized types that reference this. The type variables matching + * relies on names. Examples (in which this is named T): + *
+ * T ->>; /java/lang/Object
+ * T extends X&I -> X
+ * T extends X<String> -> X<String>
+ * T extends X<T> -> X#RAW
+ * 
+ * The result has the property of not relying upon recursion for its definition. + * @return the first upper bound of this if it does not reference this, a + * modified copy of the first upper bound of this else + */ +TypeBinding semiRawifiedFirstUpperBound() { + if (this.firstBound == null) { + return this.superclass; // java/lang/Object + } + return this.firstBound.clearedOf(this); +} + +boolean uses(TypeVariableBinding variable) { + return CharOperation.equals(variable.sourceName, this.sourceName); +} } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java,v retrieving revision 1.56 diff -u -r1.56 WildcardBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java 30 Oct 2006 22:47:40 -0000 1.56 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java 24 Nov 2006 14:19:55 -0000 @@ -624,4 +624,11 @@ } return this.typeVariable; } + +boolean uses(TypeVariableBinding variable) { + if (this.bound != null) { + return this.bound.uses(variable); + } + return false; +} }