Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 54477 Details for
Bug 163370
[1.5][compiler] Incorrect ambiguous method error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix for this bug and bug 165620 + new test case
org.eclipse.jdt.core_02.txt (text/plain), 8.42 KB, created by
Maxime Daniel
on 2006-11-24 09:24:33 EST
(
hide
)
Description:
Fix for this bug and bug 165620 + new test case
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2006-11-24 09:24:33 EST
Size:
8.42 KB
patch
obsolete
>### 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<T, U> implements I<T, U> {\n" + >+ "}\n" + >+ "interface I<T, U> { \n" + >+ "}\n" + >+ "interface J<T, U> {\n" + >+ "}\n" + >+ "class X {\n" + >+ " public static <V extends J<V, W>, W extends J<V, W>> V foo(final I<V, W> a)\n" + >+ " {\n" + >+ " return null;\n" + >+ " }\n" + >+ " public static <V extends J<V, W>, W extends J<V, W>> V foo(final Y<V, W> a)\n" + >+ " {\n" + >+ " return null;\n" + >+ " }\n" + >+ " public static <V extends J<V, W>, W extends J<V, W>> void test(final Y<V, W> 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): >+ * <pre> >+ * T ->>; /java/lang/Object >+ * T extends X&I -> X >+ * T extends X<String> -> X<String> >+ * T extends X<T> -> X#RAW >+ * </pre> >+ * 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; >+} > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 163370
:
54414
|
54477
|
55018