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 195734 Details for
Bug 334306
[1.7][compiler] name clash reported in javac 1.7 and not in javac 1.6
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + tests
patch.txt (text/plain), 17.91 KB, created by
Srikanth Sankaran
on 2011-05-16 10:33:36 EDT
(
hide
)
Description:
Proposed fix + tests
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2011-05-16 10:33:36 EDT
Size:
17.91 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.123.2.1 >diff -u -r1.123.2.1 MethodVerifier15.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 27 Apr 2011 16:33:51 -0000 1.123.2.1 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 16 May 2011 14:31:51 -0000 >@@ -235,7 +235,7 @@ > // class A implements I<Integer> { public void test(Integer i) {} } > // class B extends A { public void test(Comparable i) {} } > >- if (currentMethod.declaringClass.isInterface() || inheritedMethod.isStatic()) return; >+ if (inheritedMethod.isStatic()) return; > > if (!detectNameClash(currentMethod, inheritedMethod, false)) { // check up the hierarchy for skipped inherited methods > TypeBinding[] currentParams = currentMethod.parameters; >#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.75 >diff -u -r1.75 AmbiguousMethodTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 3 Mar 2010 18:18:56 -0000 1.75 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 16 May 2011 14:31:53 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -3269,6 +3269,7 @@ > } > > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=268837 >+// See that this test case exhibits the bug 345947 > public void test076() { > this.runNegativeTest( > new String[] { >@@ -3320,97 +3321,102 @@ > "}" > }, > "----------\n" + >- "1. ERROR in X.java (at line 15)\n" + >+ "1. ERROR in X.java (at line 8)\n" + >+ " <U> J<String> b();\n" + >+ " ^^^\n" + >+ "Name clash: The method b() of type J<E> has the same erasure as b() of type I<E> but does not override it\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 15)\n" + > " J<Integer> b = ints.a();\n" + > " ^^^^^^^^\n" + > "Type mismatch: cannot convert from J<String> to J<Integer>\n" + > "----------\n" + >- "2. ERROR in X.java (at line 16)\n" + >+ "3. ERROR in X.java (at line 16)\n" + > " J<Object> c = ints.a();\n" + > " ^^^^^^^^\n" + > "Type mismatch: cannot convert from J<String> to J<Object>\n" + > "----------\n" + >- "3. WARNING in X.java (at line 17)\n" + >+ "4. WARNING in X.java (at line 17)\n" + > " J d = ints.a();\n" + > " ^\n" + > "J is a raw type. References to generic type J<E> should be parameterized\n" + > "----------\n" + >- "4. ERROR in X.java (at line 19)\n" + >+ "5. ERROR in X.java (at line 19)\n" + > " I<Integer> f = ints.a();\n" + > " ^^^^^^^^\n" + > "Type mismatch: cannot convert from J<String> to I<Integer>\n" + > "----------\n" + >- "5. ERROR in X.java (at line 20)\n" + >+ "6. ERROR in X.java (at line 20)\n" + > " I<Object> g = ints.a();\n" + > " ^^^^^^^^\n" + > "Type mismatch: cannot convert from J<String> to I<Object>\n" + > "----------\n" + >- "6. WARNING in X.java (at line 21)\n" + >+ "7. WARNING in X.java (at line 21)\n" + > " I h = ints.a();\n" + > " ^\n" + > "I is a raw type. References to generic type I<E> should be parameterized\n" + > "----------\n" + >- "7. ERROR in X.java (at line 24)\n" + >+ "8. ERROR in X.java (at line 24)\n" + > " ints.b();\n" + > " ^\n" + > "The method b() is ambiguous for the type J<Integer>\n" + > "----------\n" + >- "8. ERROR in X.java (at line 25)\n" + >+ "9. ERROR in X.java (at line 25)\n" + > " J<String> a = ints.b();\n" + > " ^\n" + > "The method b() is ambiguous for the type J<Integer>\n" + > "----------\n" + >- "9. ERROR in X.java (at line 26)\n" + >+ "10. ERROR in X.java (at line 26)\n" + > " J<Integer> b = ints.b();\n" + > " ^\n" + > "The method b() is ambiguous for the type J<Integer>\n" + > "----------\n" + >- "10. ERROR in X.java (at line 27)\n" + >+ "11. ERROR in X.java (at line 27)\n" + > " J<Object> c = ints.b();\n" + > " ^\n" + > "The method b() is ambiguous for the type J<Integer>\n" + > "----------\n" + >- "11. WARNING in X.java (at line 28)\n" + >+ "12. WARNING in X.java (at line 28)\n" + > " J d = ints.b();\n" + > " ^\n" + > "J is a raw type. References to generic type J<E> should be parameterized\n" + > "----------\n" + >- "12. ERROR in X.java (at line 28)\n" + >+ "13. ERROR in X.java (at line 28)\n" + > " J d = ints.b();\n" + > " ^\n" + > "The method b() is ambiguous for the type J<Integer>\n" + > "----------\n" + >- "13. ERROR in X.java (at line 29)\n" + >+ "14. ERROR in X.java (at line 29)\n" + > " I<String> e = ints.b();\n" + > " ^\n" + > "The method b() is ambiguous for the type J<Integer>\n" + > "----------\n" + >- "14. ERROR in X.java (at line 30)\n" + >+ "15. ERROR in X.java (at line 30)\n" + > " I<Integer> f = ints.b();\n" + > " ^\n" + > "The method b() is ambiguous for the type J<Integer>\n" + > "----------\n" + >- "15. ERROR in X.java (at line 31)\n" + >+ "16. ERROR in X.java (at line 31)\n" + > " I<Object> g = ints.b();\n" + > " ^\n" + > "The method b() is ambiguous for the type J<Integer>\n" + > "----------\n" + >- "16. WARNING in X.java (at line 32)\n" + >+ "17. WARNING in X.java (at line 32)\n" + > " I h = ints.b();\n" + > " ^\n" + > "I is a raw type. References to generic type I<E> should be parameterized\n" + > "----------\n" + >- "17. ERROR in X.java (at line 32)\n" + >+ "18. ERROR in X.java (at line 32)\n" + > " I h = ints.b();\n" + > " ^\n" + > "The method b() is ambiguous for the type J<Integer>\n" + > "----------\n" + >- "18. WARNING in X.java (at line 39)\n" + >+ "19. WARNING in X.java (at line 39)\n" + > " J d = ints.c();\n" + > " ^\n" + > "J is a raw type. References to generic type J<E> should be parameterized\n" + > "----------\n" + >- "19. WARNING in X.java (at line 43)\n" + >+ "20. WARNING in X.java (at line 43)\n" + > " I h = ints.c();\n" + > " ^\n" + > "I is a raw type. References to generic type I<E> should be parameterized\n" + >@@ -3479,8 +3485,9 @@ > } > > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=292350 >+// See that this test case exhibits the bug 345947 > public void test079() { >- this.runConformTest( >+ this.runNegativeTest( > new String[] { > "X.java", > "interface I<T> {}\n" + >@@ -3499,7 +3506,17 @@ > " void y(Two t) { t.y(); }\n" + > "}" > }, >- "" >+ "----------\n" + >+ "1. ERROR in X.java (at line 9)\n" + >+ " <T extends A> I<T> x() throws IllegalAccessError;\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method x() of type Two has the same erasure as x() of type One but does not override it\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 10)\n" + >+ " I<B> y() throws IllegalAccessError;\n" + >+ " ^\n" + >+ "Type safety: The return type I<B> for y() from the type Two needs unchecked conversion to conform to I<A> from the type One\n" + >+ "----------\n" > ); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=293384 >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.222.2.2 >diff -u -r1.222.2.2 MethodVerifyTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 18 Mar 2011 13:09:48 -0000 1.222.2.2 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 16 May 2011 14:31:57 -0000 >@@ -2412,7 +2412,7 @@ > } > > public void test037() { // test inheritance scenarios >- this.runConformTest( >+ this.runNegativeTest( > new String[] { > "X.java", > "public abstract class X implements I, J { }\n" + >@@ -2428,8 +2428,32 @@ > "interface K extends I { void foo(A<String> a); }\n" + > "class A<T> {}" > }, >- "" >- ); >+ "----------\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " class YYY implements J, I { public void foo(A a) {} }\n" + >+ " ^\n" + >+ "A is a raw type. References to generic type A<T> should be parameterized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 5)\n" + >+ " class XXX implements I, J { public void foo(A a) {} }\n" + >+ " ^\n" + >+ "A is a raw type. References to generic type A<T> should be parameterized\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 6)\n" + >+ " class ZZZ implements K { public void foo(A a) {} }\n" + >+ " ^\n" + >+ "A is a raw type. References to generic type A<T> should be parameterized\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 7)\n" + >+ " interface I { void foo(A a); }\n" + >+ " ^\n" + >+ "A is a raw type. References to generic type A<T> should be parameterized\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 9)\n" + >+ " interface K extends I { void foo(A<String> a); }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(A<String>) of type K has the same erasure as foo(A) of type I but does not override it\n" + >+ "----------\n"); > } > public void test037a() { // test inheritance scenarios > this.runNegativeTest( >@@ -2467,43 +2491,47 @@ > "interface K extends I { void foo(A<String> a); }\n" + > "class A<T> {}" > }, >- "----------\n" + >- "1. ERROR in XX.java (at line 1)\n" + >- " public class XX implements I, J { public void foo(A<String> a) {} }\n" + >- " ^^\n" + >- "The type XX must implement the inherited abstract method I.foo(A)\n" + >- "----------\n" + >- "2. ERROR in XX.java (at line 1)\n" + >- " public class XX implements I, J { public void foo(A<String> a) {} }\n" + >- " ^^^^^^^^^^^^^^^^\n" + >- "Name clash: The method foo(A<String>) of type XX has the same erasure as foo(A) of type I but does not override it\n" + >- "----------\n" + >- "3. ERROR in XX.java (at line 2)\n" + >- " class YY implements J, I { public void foo(A<String> a) {} }\n" + >- " ^^\n" + >- "The type YY must implement the inherited abstract method I.foo(A)\n" + >- "----------\n" + >- "4. ERROR in XX.java (at line 2)\n" + >- " class YY implements J, I { public void foo(A<String> a) {} }\n" + >- " ^^^^^^^^^^^^^^^^\n" + >- "Name clash: The method foo(A<String>) of type YY has the same erasure as foo(A) of type I but does not override it\n" + >- "----------\n" + >- "5. ERROR in XX.java (at line 3)\n" + >- " class ZZ implements K { public void foo(A<String> a) {} }\n" + >- " ^^\n" + >- "The type ZZ must implement the inherited abstract method I.foo(A)\n" + >- "----------\n" + >- "6. ERROR in XX.java (at line 3)\n" + >- " class ZZ implements K { public void foo(A<String> a) {} }\n" + >- " ^^^^^^^^^^^^^^^^\n" + >- "Name clash: The method foo(A<String>) of type ZZ has the same erasure as foo(A) of type I but does not override it\n" + >- "----------\n" + >- "7. WARNING in XX.java (at line 4)\n" + >- " interface I { void foo(A a); }\n" + >- " ^\n" + >- "A is a raw type. References to generic type A<T> should be parameterized\n" + >+ "----------\n" + >+ "1. ERROR in XX.java (at line 1)\n" + >+ " public class XX implements I, J { public void foo(A<String> a) {} }\n" + >+ " ^^\n" + >+ "The type XX must implement the inherited abstract method I.foo(A)\n" + >+ "----------\n" + >+ "2. ERROR in XX.java (at line 1)\n" + >+ " public class XX implements I, J { public void foo(A<String> a) {} }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(A<String>) of type XX has the same erasure as foo(A) of type I but does not override it\n" + >+ "----------\n" + >+ "3. ERROR in XX.java (at line 2)\n" + >+ " class YY implements J, I { public void foo(A<String> a) {} }\n" + >+ " ^^\n" + >+ "The type YY must implement the inherited abstract method I.foo(A)\n" + >+ "----------\n" + >+ "4. ERROR in XX.java (at line 2)\n" + >+ " class YY implements J, I { public void foo(A<String> a) {} }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(A<String>) of type YY has the same erasure as foo(A) of type I but does not override it\n" + >+ "----------\n" + >+ "5. ERROR in XX.java (at line 3)\n" + >+ " class ZZ implements K { public void foo(A<String> a) {} }\n" + >+ " ^^\n" + >+ "The type ZZ must implement the inherited abstract method I.foo(A)\n" + >+ "----------\n" + >+ "6. ERROR in XX.java (at line 3)\n" + >+ " class ZZ implements K { public void foo(A<String> a) {} }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(A<String>) of type ZZ has the same erasure as foo(A) of type I but does not override it\n" + >+ "----------\n" + >+ "7. WARNING in XX.java (at line 4)\n" + >+ " interface I { void foo(A a); }\n" + >+ " ^\n" + >+ "A is a raw type. References to generic type A<T> should be parameterized\n" + >+ "----------\n" + >+ "8. ERROR in XX.java (at line 6)\n" + >+ " interface K extends I { void foo(A<String> a); }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(A<String>) of type K has the same erasure as foo(A) of type I but does not override it\n" + > "----------\n" >- // XX/YY/ZZ is not abstract and does not override abstract method foo(A) in I > ); > } > public void test037c() { // test inheritance scenarios >@@ -8619,6 +8647,7 @@ > ""); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=194034 >+// See that this test case exhibits the bug 345947 > public void test144() { > this.runNegativeTest( > new String[] { >@@ -8636,11 +8665,16 @@ > "}\n" + > "class PurebredCatShopImpl extends CatShopImpl implements PurebredCatShop {}" > }, >- "----------\n" + >- "1. WARNING in PurebredCatShopImpl.java (at line 10)\n" + >- " public List<Pet> getPets() { return null; }\n" + >- " ^^^^\n" + >- "Type safety: The return type List<Pet> for getPets() from the type CatShopImpl needs unchecked conversion to conform to List<? extends Cat> from the type CatShop\n" + >+ "----------\n" + >+ "1. ERROR in PurebredCatShopImpl.java (at line 6)\n" + >+ " <V extends Pet> List<? extends Cat> getPets();\n" + >+ " ^^^^^^^^^\n" + >+ "Name clash: The method getPets() of type CatShop has the same erasure as getPets() of type PetShop but does not override it\n" + >+ "----------\n" + >+ "2. WARNING in PurebredCatShopImpl.java (at line 10)\n" + >+ " public List<Pet> getPets() { return null; }\n" + >+ " ^^^^\n" + >+ "Type safety: The return type List<Pet> for getPets() from the type CatShopImpl needs unchecked conversion to conform to List<? extends Cat> from the type CatShop\n" + > "----------\n" > ); > } >@@ -12063,4 +12097,51 @@ > assertEquals("Wrong contents", expectedOutput, result); > } > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322740 >+public void test322740() throws Exception { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class Base {\n" + >+ " boolean equalTo(Object other) {return false;}\n" + >+ "}\n" + >+ "interface EqualityComparable<T> {\n" + >+ " boolean equalTo(T other);\n" + >+ "}\n" + >+ "public class X extends Base implements EqualityComparable<String> {\n" + >+ " public boolean equalTo(String other) {\n" + >+ " return true;\n" + >+ " }\n" + >+ " public static void main(String args[]) {\n" + >+ " new X().equalTo(args);\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " public class X extends Base implements EqualityComparable<String> {\n" + >+ " ^\n" + >+ "Name clash: The method equalTo(T) of type EqualityComparable<T> has the same erasure as equalTo(Object) of type Base but does not override it\n" + >+ "----------\n"); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=334306 >+public void test334306() throws Exception { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class X<T> {}\n" + >+ "interface I {\n" + >+ " void foo(X<Number> p);\n" + >+ "}\n" + >+ "interface J extends I {\n" + >+ " void foo(X<Integer> p);\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " void foo(X<Integer> p);\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(X<Integer>) of type J has the same erasure as foo(X<Number>) of type I but does not override it\n" + >+ "----------\n"); >+} > }
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 334306
:
186774
|
186775
| 195734