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 61057 Details for
Bug 174445
[1.5][compiler] missing unchecked conversion warning upon parametrized method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Tentative fix + test case
patch.txt (text/plain), 12.26 KB, created by
Maxime Daniel
on 2007-03-16 03:24:10 EDT
(
hide
)
Description:
Tentative fix + test case
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2007-03-16 03:24:10 EDT
Size:
12.26 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java,v >retrieving revision 1.120 >diff -u -r1.120 MethodVerifyTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 12 Mar 2007 08:14:52 -0000 1.120 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 16 Mar 2007 07:20:44 -0000 >@@ -7510,4 +7510,43 @@ > "The method bar(String, String) of type X is not generic; it cannot be parameterized with arguments <String>\n" + > "----------\n"); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=174445 >+public void test127() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " enum Enum1 {\n" + >+ " value;\n" + >+ " }\n" + >+ " enum Enum2 {\n" + >+ " value;\n" + >+ " }\n" + >+ " static abstract class A<T> {\n" + >+ " abstract <U extends T> U foo();\n" + >+ " }\n" + >+ " static class B extends A<Enum<?>> {\n" + >+ " @Override\n" + >+ " Enum<?> foo() {\n" + >+ " return Enum1.value;\n" + >+ " } \n" + >+ " }\n" + >+ " public static void main(String[] args) {\n" + >+ " A<Enum<?>> a = new B();\n" + >+ " Enum2 value = a.foo();\n" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 13)\n" + >+ " Enum<?> foo() {\n" + >+ " ^^^^\n" + >+ "Type safety: The return type Enum<?> for foo() from the type X.B needs unchecked conversion to conform to Enum<E> from the type X.A<Enum<?>>\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 13)\n" + >+ " Enum<?> foo() {\n" + >+ " ^^^^\n" + >+ "Type safety: The return type Enum<?> for foo() from the type X.B needs unchecked conversion to conform to U from the type X.A<T>\n" + >+ "----------\n"); >+} > } >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java,v >retrieving revision 1.70 >diff -u -r1.70 MethodVerifier15.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 12 Mar 2007 08:14:55 -0000 1.70 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 16 Mar 2007 07:20:54 -0000 >@@ -20,7 +20,7 @@ > super(environment); > } > boolean areMethodsEqual(MethodBinding one, MethodBinding two) { >- MethodBinding sub = computeSubstituteMethod(two, one); >+ MethodBinding sub = computeSubstituteMethod(two, one, false); > return sub != null && doesSubstituteMethodOverride(one, sub) && areReturnTypesEqual(one, sub); > } > boolean areParametersEqual(MethodBinding one, MethodBinding two) { >@@ -155,7 +155,7 @@ > MethodBinding compareMethod = inheritedMethod instanceof ParameterizedGenericMethodBinding > ? ((ParameterizedGenericMethodBinding) inheritedMethod).originalMethod > : inheritedMethod; >- MethodBinding substitute = computeSubstituteMethod(otherInheritedMethod, compareMethod); >+ MethodBinding substitute = computeSubstituteMethod(otherInheritedMethod, compareMethod, false); > if (substitute == null || doesSubstituteMethodOverride(compareMethod, substitute)) > continue; > if (detectInheritedNameClash(originalInherited, otherOriginal)) >@@ -238,7 +238,7 @@ > while (superType != null && superType.isValidBinding()) { > MethodBinding[] methods = superType.getMethods(currentMethod.selector); > for (int m = 0, n = methods.length; m < n; m++) { >- MethodBinding substitute = computeSubstituteMethod(methods[m], currentMethod); >+ MethodBinding substitute = computeSubstituteMethod(methods[m], currentMethod, false); > if (substitute != null && !doesSubstituteMethodOverride(currentMethod, substitute) && detectNameClash(currentMethod, substitute)) > return; > } >@@ -266,7 +266,7 @@ > if (superType.isValidBinding()) { > MethodBinding[] methods = superType.getMethods(currentMethod.selector); > for (int m = 0, n = methods.length; m < n; m++){ >- MethodBinding substitute = computeSubstituteMethod(methods[m], currentMethod); >+ MethodBinding substitute = computeSubstituteMethod(methods[m], currentMethod, false); > if (substitute != null && !doesSubstituteMethodOverride(currentMethod, substitute) && detectNameClash(currentMethod, substitute)) > return; > } >@@ -360,7 +360,7 @@ > MethodBinding inheritedMethod; > if (i != j && (inheritedMethod = methodsToCheck[j]) != null && > existingMethod.declaringClass.implementsInterface(inheritedMethod.declaringClass, true)) { >- MethodBinding substitute = computeSubstituteMethod(inheritedMethod, existingMethod); >+ MethodBinding substitute = computeSubstituteMethod(inheritedMethod, existingMethod, false); > if (substitute != null && > doesSubstituteMethodOverride(existingMethod, substitute) && > (existingMethod.returnType.isCompatibleWith(substitute.returnType) || >@@ -426,7 +426,7 @@ > for (int i = 0, length1 = current.length; i < length1; i++) { > MethodBinding currentMethod = current[i]; > for (int j = 0, length2 = inherited.length; j < length2; j++) { >- MethodBinding inheritedMethod = computeSubstituteMethod(inherited[j], currentMethod); >+ MethodBinding inheritedMethod = computeSubstituteMethod(inherited[j], currentMethod, true); > if (inheritedMethod != null) { > if (foundMatch[j] == 0 && doesSubstituteMethodOverride(currentMethod, inheritedMethod)) { > matchingInherited[++index] = inheritedMethod; >@@ -455,7 +455,7 @@ > MethodBinding otherInheritedMethod = inherited[j]; > if (foundMatch[j] == 1 || canSkipInheritedMethods(inheritedMethod, otherInheritedMethod)) > continue; >- otherInheritedMethod = computeSubstituteMethod(otherInheritedMethod, inheritedMethod); >+ otherInheritedMethod = computeSubstituteMethod(otherInheritedMethod, inheritedMethod, false); > if (otherInheritedMethod != null) { > if (doesSubstituteMethodOverride(inheritedMethod, otherInheritedMethod)) { > matchingInherited[++index] = otherInheritedMethod; >@@ -493,7 +493,7 @@ > MethodBinding otherInheritedMethod = inherited[j]; > if (canSkipInheritedMethods(inheritedMethod, otherInheritedMethod)) > continue; >- otherInheritedMethod = computeSubstituteMethod(otherInheritedMethod, inheritedMethod); >+ otherInheritedMethod = computeSubstituteMethod(otherInheritedMethod, inheritedMethod, false); > if (otherInheritedMethod != null && doesSubstituteMethodOverride(inheritedMethod, otherInheritedMethod)) { > matchingInherited[++index] = otherInheritedMethod; > inherited[j] = null; // do not want to find it again >@@ -512,7 +512,7 @@ > } > } > } >-MethodBinding computeSubstituteMethod(MethodBinding inheritedMethod, MethodBinding currentMethod) { >+MethodBinding computeSubstituteMethod(MethodBinding inheritedMethod, MethodBinding currentMethod, boolean eraseIfTypeParametersNbMismatch) { > if (inheritedMethod == null) return null; > if (currentMethod.parameters.length != inheritedMethod.parameters.length) return null; // no match > >@@ -527,14 +527,21 @@ > int inheritedLength = inheritedTypeVariables.length; > TypeVariableBinding[] typeVariables = currentMethod.typeVariables; > int length = typeVariables.length; >- if (length > 0 && inheritedLength != length) return inheritedMethod; >+ if (length > 0 && inheritedLength != length) return inheritedMethod; // no match JLS 8.4.2 > TypeBinding[] arguments = new TypeBinding[inheritedLength]; >- if (inheritedLength <= length) { >+ if (length != 0) { > System.arraycopy(typeVariables, 0, arguments, 0, inheritedLength); >+ } else if (eraseIfTypeParametersNbMismatch) { >+ // length is null >+ for (int i = 0; i < inheritedLength; i++) { >+ arguments[i] = inheritedTypeVariables[i].erasure(); >+ } >+ return this.environment.createParameterizedGenericMethod(inheritedMethod, arguments); // erasure > } else { >- System.arraycopy(typeVariables, 0, arguments, 0, length); >- for (int i = length; i < inheritedLength; i++) >+ // length is null >+ for (int i = 0; i < inheritedLength; i++) { > arguments[i] = inheritedTypeVariables[i].upperBound(); >+ } > } > ParameterizedGenericMethodBinding substitute = > this.environment.createParameterizedGenericMethod(inheritedMethod, arguments); >@@ -589,7 +596,7 @@ > return true; > } > public boolean doesMethodOverride(MethodBinding method, MethodBinding inheritedMethod) { >- MethodBinding substitute = computeSubstituteMethod(inheritedMethod, method); >+ MethodBinding substitute = computeSubstituteMethod(inheritedMethod, method, false); > return substitute != null && doesSubstituteMethodOverride(method, substitute); > } > boolean doesSubstituteMethodOverride(MethodBinding method, MethodBinding substituteMethod) { >@@ -627,7 +634,7 @@ > if (inheritedMethod.original() != inheritedMethod && existingMethod.declaringClass.isInterface()) > return false; // must hold onto ParameterizedMethod to see if a bridge method is necessary > >- inheritedMethod = computeSubstituteMethod(inheritedMethod, existingMethod); >+ inheritedMethod = computeSubstituteMethod(inheritedMethod, existingMethod, false); > return inheritedMethod != null > && inheritedMethod.returnType == existingMethod.returnType > && super.isInterfaceMethodImplemented(inheritedMethod, existingMethod, superType); >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java,v >retrieving revision 1.82 >diff -u -r1.82 MethodVerifier.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java 6 Mar 2007 02:38:51 -0000 1.82 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java 16 Mar 2007 07:20:54 -0000 >@@ -324,7 +324,7 @@ > for (int i = 0, length1 = current.length; i < length1; i++) { > MethodBinding currentMethod = current[i]; > for (int j = 0, length2 = inherited.length; j < length2; j++) { >- MethodBinding inheritedMethod = computeSubstituteMethod(inherited[j], currentMethod); >+ MethodBinding inheritedMethod = computeSubstituteMethod(inherited[j], currentMethod, false); > if (inheritedMethod != null) { > if (doesMethodOverride(currentMethod, inheritedMethod)) { > matchingInherited[++index] = inheritedMethod; >@@ -348,7 +348,7 @@ > MethodBinding otherInheritedMethod = inherited[j]; > if (canSkipInheritedMethods(inheritedMethod, otherInheritedMethod)) > continue; >- otherInheritedMethod = computeSubstituteMethod(otherInheritedMethod, inheritedMethod); >+ otherInheritedMethod = computeSubstituteMethod(otherInheritedMethod, inheritedMethod, false); > if (otherInheritedMethod != null) { > if (doesMethodOverride(inheritedMethod, otherInheritedMethod)) { > matchingInherited[++index] = otherInheritedMethod; >@@ -564,7 +564,7 @@ > } > } > } >-MethodBinding computeSubstituteMethod(MethodBinding inheritedMethod, MethodBinding currentMethod) { >+MethodBinding computeSubstituteMethod(MethodBinding inheritedMethod, MethodBinding currentMethod, boolean eraseIfTypeParametersNbMismatch) { > if (inheritedMethod == null) return null; > if (currentMethod.parameters.length != inheritedMethod.parameters.length) return null; // no match > return inheritedMethod; >Index: .settings/org.eclipse.jdt.core.prefs >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/.settings/org.eclipse.jdt.core.prefs,v >retrieving revision 1.10 >diff -u -r1.10 org.eclipse.jdt.core.prefs >--- .settings/org.eclipse.jdt.core.prefs 15 Mar 2007 14:25:16 -0000 1.10 >+++ .settings/org.eclipse.jdt.core.prefs 16 Mar 2007 07:20:52 -0000 >@@ -1,4 +1,4 @@ >-#Thu Mar 15 15:21:08 CET 2007 >+#Fri Mar 16 07:57:10 CET 2007 > eclipse.preferences.version=1 > org.eclipse.jdt.core.builder.cleanOutputFolder=clean > org.eclipse.jdt.core.builder.duplicateResourceTask=warning
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 174445
:
60532
|
60533
| 61057 |
61146