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 123585 Details for
Bug 262208
[1.5][compiler]Incorrect @Override and name clash errors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch and testcase for 3.4.2
verifierpatch.txt (text/plain), 6.38 KB, created by
Kent Johnson
on 2009-01-23 14:57:50 EST
(
hide
)
Description:
Proposed patch and testcase for 3.4.2
Filename:
MIME Type:
Creator:
Kent Johnson
Created:
2009-01-23 14:57:50 EST
Size:
6.38 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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.88.2.5 >diff -u -r1.88.2.5 MethodVerifier15.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 4 Nov 2008 17:04:50 -0000 1.88.2.5 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 23 Jan 2009 19:48:43 -0000 >@@ -533,25 +533,22 @@ > ((BinaryTypeBinding) inheritedMethod.declaringClass).resolveTypesFor(inheritedMethod); > > TypeVariableBinding[] inheritedTypeVariables = inheritedMethod.typeVariables; >- if (inheritedTypeVariables == Binding.NO_TYPE_VARIABLES) return inheritedMethod; > int inheritedLength = inheritedTypeVariables.length; >+ if (inheritedLength == 0) return inheritedMethod; // no substitution needed > TypeVariableBinding[] typeVariables = currentMethod.typeVariables; > int length = typeVariables.length; >- if (length > 0 && inheritedLength != length) return inheritedMethod; // no match JLS 8.4.2 >- TypeBinding[] arguments = new TypeBinding[inheritedLength]; >- if (inheritedLength <= length) { >- System.arraycopy(typeVariables, 0, arguments, 0, inheritedLength); >- } else { >- System.arraycopy(typeVariables, 0, arguments, 0, length); >- for (int i = length; i < inheritedLength; i++) >- arguments[i] = inheritedTypeVariables[i].upperBound(); >- } >- ParameterizedGenericMethodBinding substitute = >- this.environment.createParameterizedGenericMethod(inheritedMethod, arguments); >+ if (length == 0) >+ return inheritedMethod.asRawMethod(this.environment); >+ if (length != inheritedLength) >+ return inheritedMethod; // no match JLS 8.4.2 > > // interface I { <T> void foo(T t); } > // class X implements I { public <T extends I> void foo(T t) {} } > // for the above case, we do not want to answer the substitute method since its not a match >+ TypeBinding[] arguments = new TypeBinding[length]; >+ System.arraycopy(typeVariables, 0, arguments, 0, length); >+ ParameterizedGenericMethodBinding substitute = >+ this.environment.createParameterizedGenericMethod(inheritedMethod, arguments); > for (int i = 0; i < inheritedLength; i++) { > TypeVariableBinding inheritedTypeVariable = inheritedTypeVariables[i]; > TypeBinding argument = arguments[i]; >#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.153.2.5 >diff -u -r1.153.2.5 MethodVerifyTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 4 Nov 2008 17:04:51 -0000 1.153.2.5 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 23 Jan 2009 19:48:44 -0000 >@@ -7708,7 +7708,12 @@ > "}" > }, > "----------\n" + >- "1. WARNING in X.java (at line 10)\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " public A foo(Number n) { return null; }\n" + >+ " ^\n" + >+ "Type safety: The return type A for foo(Number) from the type X2 needs unchecked conversion to conform to T from the type I\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 10)\n" + > " A foo(Number n);\n" + > " ^\n" + > "Type safety: The return type A for foo(Number) from the type J needs unchecked conversion to conform to T from the type I\n" + >@@ -7792,7 +7797,7 @@ > "1. WARNING in X.java (at line 6)\n" + > " A<XX> foo(Number n);\n" + > " ^\n" + >- "Type safety: The return type A<XX> for foo(Number) from the type J needs unchecked conversion to conform to A<T> from the type I\n" + >+ "Type safety: The return type A<XX> for foo(Number) from the type J needs unchecked conversion to conform to A<Exception&Cloneable> from the type I\n" + > "----------\n" > ); > } >@@ -7817,7 +7822,12 @@ > "}" > }, > "----------\n" + >- "1. WARNING in X.java (at line 9)\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " public XX foo(Number n) { return null; }\n" + >+ " ^^\n" + >+ "Type safety: The return type XX for foo(Number) from the type X needs unchecked conversion to conform to T from the type I\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 9)\n" + > " XX foo(Number n);\n" + > " ^^\n" + > "Type safety: The return type XX for foo(Number) from the type J needs unchecked conversion to conform to T from the type I\n" + >@@ -8904,4 +8914,48 @@ > "" > ); > } >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=262208 >+public void test183() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class XX {\n" + >+ " <T extends C, S extends G<T>> void a(S gC) {}\n" + >+ " <T extends C, S extends G<T>> void b(T c) {}\n" + >+ " <T extends C> void c(G<T> gC) {}\n" + >+ " <T extends C, S extends G<T>> void d(S gC) {}\n" + >+ "}\n" + >+ "class X extends XX {\n" + >+ " @Override void a(G g) {}\n" + >+ " @Override void b(C c) {}\n" + >+ " @Override void c(G g) {}\n" + >+ " @Override <T extends C, S extends G<C>> void d(S gc) {}\n" + >+ "}\n" + >+ "class C {}\n" + >+ "class G<T2> {}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 8)\n" + >+ " @Override void a(G g) {}\n" + >+ " ^\n" + >+ "G is a raw type. References to generic type G<T2> should be parameterized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 10)\n" + >+ " @Override void c(G g) {}\n" + >+ " ^\n" + >+ "G is a raw type. References to generic type G<T2> should be parameterized\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 11)\n" + >+ " @Override <T extends C, S extends G<C>> void d(S gc) {}\n" + >+ " ^^^^^^^\n" + >+ "Name clash: The method d(S) of type X has the same erasure as d(S) of type XX but does not override it\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 11)\n" + >+ " @Override <T extends C, S extends G<C>> void d(S gc) {}\n" + >+ " ^^^^^^^\n" + >+ mustOverrideMessage("d(S)", "X") + >+ "----------\n" >+ ); >+} > } >\ No newline at end of file
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 262208
:
123561
| 123585