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 126344 Details for
Bug 206930
[1.5][compiler] Mismatch between javac and Eclipse compiler
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch and testcase
patch.txt (text/plain), 14.45 KB, created by
Kent Johnson
on 2009-02-20 15:15:40 EST
(
hide
)
Description:
Proposed patch and testcase
Filename:
MIME Type:
Creator:
Kent Johnson
Created:
2009-02-20 15:15:40 EST
Size:
14.45 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v >retrieving revision 1.349 >diff -u -r1.349 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 23 Jan 2009 19:50:21 -0000 1.349 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 20 Feb 2009 20:14:53 -0000 >@@ -898,7 +898,7 @@ > // in >= 1.5 mode, ensure the exactMatch did not match raw types > if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) > for (int i = argumentTypes.length; --i >= 0;) >- if (argumentTypes[i].isRawType()) >+ if (isSubtypeOfRawType(argumentTypes[i])) > return null; > // must find both methods for this case: <S extends A> void foo() {} and <N extends B> N foo() { return null; } > // or find an inherited method when the exact match is to a bridge method >@@ -2784,22 +2784,27 @@ > if (oneParam == twoParam || oneParam.isCompatibleWith(twoParam)) { > if (two.declaringClass.isRawType()) continue next; > >- TypeBinding originalOneParam = one.original().parameters[i].leafComponentType(); >- switch (originalOneParam.kind()) { >+ TypeBinding originalTwoParam = two.original().parameters[i].leafComponentType(); >+ switch (originalTwoParam.kind()) { > case Binding.TYPE_PARAMETER : >- if (!((TypeVariableBinding) originalOneParam).upperBound().isRawType()) break; >+ if (((TypeVariableBinding) originalTwoParam).hasOnlyRawBounds()) >+ continue next; > //$FALL-THROUGH$ >- case Binding.RAW_TYPE: >- // originalOneParam is RAW so it cannot be more specific than a wildcard or parameterized type >- TypeBinding originalTwoParam = two.original().parameters[i].leafComponentType(); >- switch (originalTwoParam.kind()) { >+ case Binding.WILDCARD_TYPE : >+ case Binding.INTERSECTION_TYPE: >+ case Binding.PARAMETERIZED_TYPE : >+ TypeBinding originalOneParam = one.original().parameters[i].leafComponentType(); >+ switch (originalOneParam.kind()) { >+ case Binding.TYPE : >+ case Binding.GENERIC_TYPE : >+ TypeBinding inheritedTwoParam = oneParam.findSuperTypeOriginatingFrom(twoParam); >+ if (inheritedTwoParam == null || !inheritedTwoParam.leafComponentType().isRawType()) break; >+ return false; > case Binding.TYPE_PARAMETER : >- if (((TypeVariableBinding) originalTwoParam).hasOnlyRawBounds()) >- continue next; >- return false; >- case Binding.WILDCARD_TYPE : >- case Binding.INTERSECTION_TYPE: >- case Binding.PARAMETERIZED_TYPE : >+ if (!((TypeVariableBinding) originalOneParam).upperBound().isRawType()) break; >+ return false; >+ case Binding.RAW_TYPE: >+ // originalOneParam is RAW so it cannot be more specific than a wildcard or parameterized type > return false; > } > } >@@ -2970,6 +2975,55 @@ > return false; > } > >+ public boolean isSubtypeOfRawType(TypeBinding paramType) { >+ TypeBinding t = paramType.leafComponentType(); >+ if (t.isBaseType()) return false; >+ >+ ReferenceBinding currentType = (ReferenceBinding) t; >+ ReferenceBinding[] interfacesToVisit = null; >+ int nextPosition = 0; >+ do { >+ if (currentType.isRawType()) return true; >+ >+ ReferenceBinding[] itsInterfaces = currentType.superInterfaces(); >+ if (itsInterfaces != null && itsInterfaces != Binding.NO_SUPERINTERFACES) { >+ if (interfacesToVisit == null) { >+ interfacesToVisit = itsInterfaces; >+ nextPosition = interfacesToVisit.length; >+ } else { >+ int itsLength = itsInterfaces.length; >+ if (nextPosition + itsLength >= interfacesToVisit.length) >+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition); >+ nextInterface : for (int a = 0; a < itsLength; a++) { >+ ReferenceBinding next = itsInterfaces[a]; >+ for (int b = 0; b < nextPosition; b++) >+ if (next == interfacesToVisit[b]) continue nextInterface; >+ interfacesToVisit[nextPosition++] = next; >+ } >+ } >+ } >+ } while ((currentType = currentType.superclass()) != null); >+ >+ for (int i = 0; i < nextPosition; i++) { >+ currentType = interfacesToVisit[i]; >+ if (currentType.isRawType()) return true; >+ >+ ReferenceBinding[] itsInterfaces = currentType.superInterfaces(); >+ if (itsInterfaces != null && itsInterfaces != Binding.NO_SUPERINTERFACES) { >+ int itsLength = itsInterfaces.length; >+ if (nextPosition + itsLength >= interfacesToVisit.length) >+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition); >+ nextInterface : for (int a = 0; a < itsLength; a++) { >+ ReferenceBinding next = itsInterfaces[a]; >+ for (int b = 0; b < nextPosition; b++) >+ if (next == interfacesToVisit[b]) continue nextInterface; >+ interfacesToVisit[nextPosition++] = next; >+ } >+ } >+ } >+ return false; >+ } >+ > private TypeBinding leastContainingInvocation(TypeBinding mec, Object invocationData, List lubStack) { > if (invocationData == null) return mec; // no alternate invocation > if (invocationData instanceof TypeBinding) { // only one invocation, simply return it (array only allocated if more than one) >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java,v >retrieving revision 1.118 >diff -u -r1.118 AbstractRegressionTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java 3 Dec 2008 14:36:36 -0000 1.118 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java 20 Feb 2009 20:14:55 -0000 >@@ -327,8 +327,6 @@ > public static EclipseHasABug > EclipseBug159851 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=159851 > new EclipseHasABug(MismatchType.JavacErrorsEclipseNone) : null, >- EclipseBug166355 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=166355 >- new EclipseHasABug(MismatchType.JavacErrorsEclipseWarnings) : null, > EclipseBug177715 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=177715 > new EclipseHasABug(MismatchType.JavacErrorsEclipseNone) : null, > EclipseBug207935 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=207935 >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.60 >diff -u -r1.60 AmbiguousMethodTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 23 Jan 2009 19:50:20 -0000 1.60 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 20 Feb 2009 20:14:55 -0000 >@@ -2163,9 +2163,7 @@ > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=166355 > public void test051() { >- this.runConformTest( >- // test directory preparation >- true /* flush output directory */, >+ this.runNegativeTest( > new String[] { /* test files */ > "X.java", > "interface I<T> {\n" + >@@ -2184,23 +2182,17 @@ > " }\n" + > "}\n" > }, >- // compiler results >- "----------\n" + /* expected compiler log */ >- "1. WARNING in X.java (at line 9)\n" + >- " bar(new Z());\n" + >- " ^^^^^^^\n" + >- "Access to enclosing constructor X.Z() is emulated by a synthetic accessor method\n" + >- "----------\n" + >- "2. WARNING in X.java (at line 13)\n" + >- " private static final class Z implements I {\n" + >- " ^\n" + >- "I is a raw type. References to generic type I<T> should be parameterized\n" + >- "----------\n", >- // runtime options >- "" /* expected output string */, >- "" /* do not check error string */, >- // javac options >- JavacTestOptions.EclipseHasABug.EclipseBug166355 /* javac test options */); >+ "----------\n" + >+ "1. ERROR in X.java (at line 9)\n" + >+ " bar(new Z());\n" + >+ " ^^^\n" + >+ "The method bar(X.Z) is ambiguous for the type X\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 13)\n" + >+ " private static final class Z implements I {\n" + >+ " ^\n" + >+ "I is a raw type. References to generic type I<T> should be parameterized\n" + >+ "----------\n"); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=166355 > // variant >@@ -2229,9 +2221,7 @@ > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=166355 > // variant > public void test053() { >- this.runConformTest( >- // test directory preparation >- true /* flush output directory */, >+ this.runNegativeTest( > new String[] { /* test files */ > "X.java", > "interface I<T> {\n" + >@@ -2250,23 +2240,17 @@ > " }\n" + > "}\n" > }, >- // compiler results >- "----------\n" + /* expected compiler log */ >- "1. WARNING in X.java (at line 9)\n" + >- " bar(new Z(){});\n" + >- " ^^^\n" + >- "Access to enclosing constructor X.Z() is emulated by a synthetic accessor method\n" + >- "----------\n" + >- "2. WARNING in X.java (at line 13)\n" + >- " private static class Z implements I {\n" + >- " ^\n" + >- "I is a raw type. References to generic type I<T> should be parameterized\n" + >- "----------\n", >- // runtime results >- "" /* expected output string */, >- "" /* expected error string */, >- // javac options >- JavacTestOptions.EclipseHasABug.EclipseBug166355 /* javac test options */); >+ "----------\n" + >+ "1. ERROR in X.java (at line 9)\n" + >+ " bar(new Z(){});\n" + >+ " ^^^\n" + >+ "The method bar(X.Z) is ambiguous for the type X\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 13)\n" + >+ " private static class Z implements I {\n" + >+ " ^\n" + >+ "I is a raw type. References to generic type I<T> should be parameterized\n" + >+ "----------\n"); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=166355 > // variant >@@ -2937,4 +2921,120 @@ > "----------\n" > ); > } >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=206930 >+public void test074() { >+ this.runNegativeTest( >+ new String[] { >+ "Y.java", >+ "interface I<T> {}\n" + >+ "class A {\n" + >+ " void a(I x) {}\n" + >+ " void b(I<?> x) {}\n" + >+ " void b(I<?>[] x) {}\n" + >+ " <U> void c(I<?> x) {}\n" + >+ "}\n" + >+ "class B extends A {}\n" + >+ "class C extends B implements I {\n" + >+ " void a(C c) {}\n" + >+ " void b(C c) {}\n" + >+ " void b(C[] c) {}\n" + >+ " void c(C c) {}\n" + >+ "}\n" + >+ "class D extends C {\n" + >+ " void test() {\n" + >+ " a(new C());\n" + >+ " a(new D());\n" + >+ " b(new C());\n" + // ambiguous b(I<?>) in A and b(C) in C match >+ " b(new D());\n" + // ambiguous b(I<?>) in A and b(C) in C match >+ " b(new C[0]);\n" + // ambiguous b(I<?>[]) in A and b(C[]) in C match >+ " b(new D[0]);\n" + // ambiguous b(I<?>[]) in A and b(C[]) in C match >+ " c(new C());\n" + // ambiguous <U>c(I<?>) in A and c(C) in C match >+ " c(new D());\n" + // ambiguous <U>c(I<?>) in A and c(C) in C match >+ " }\n" + >+ "}\n" + >+ "class A2<T> {\n" + >+ " void a(I x) {}\n" + >+ " void b(I<?> x) {}\n" + >+ " <U> void c(I<?> x) {}\n" + >+ " void d(I<T> x) {}\n" + >+ "}\n" + >+ "class B2 extends A2 {}\n" + >+ "class C2 extends B2 implements I {\n" + >+ " void a(C2 c) {}\n" + >+ " void b(C2 c) {}\n" + >+ " void c(C2 c) {}\n" + >+ " void d(C2 c) {}\n" + >+ "}\n" + >+ "class D2 extends C2 {\n" + >+ " void test() {\n" + >+ " a(new C2());\n" + >+ " a(new D2());\n" + >+ " b(new C2());\n" + >+ " b(new D2());\n" + >+ " c(new C2());\n" + >+ " c(new D2());\n" + >+ " d(new C2());\n" + >+ " d(new D2());\n" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in Y.java (at line 3)\n" + >+ " void a(I x) {}\n" + >+ " ^\n" + >+ "I is a raw type. References to generic type I<T> should be parameterized\n" + >+ "----------\n" + >+ "2. WARNING in Y.java (at line 9)\n" + >+ " class C extends B implements I {\n" + >+ " ^\n" + >+ "I is a raw type. References to generic type I<T> should be parameterized\n" + >+ "----------\n" + >+ "3. ERROR in Y.java (at line 19)\n" + >+ " b(new C());\n" + >+ " ^\n" + >+ "The method b(C) is ambiguous for the type D\n" + >+ "----------\n" + >+ "4. ERROR in Y.java (at line 20)\n" + >+ " b(new D());\n" + >+ " ^\n" + >+ "The method b(C) is ambiguous for the type D\n" + >+ "----------\n" + >+ "5. ERROR in Y.java (at line 21)\n" + >+ " b(new C[0]);\n" + >+ " ^\n" + >+ "The method b(C[]) is ambiguous for the type D\n" + >+ "----------\n" + >+ "6. ERROR in Y.java (at line 22)\n" + >+ " b(new D[0]);\n" + >+ " ^\n" + >+ "The method b(C[]) is ambiguous for the type D\n" + >+ "----------\n" + >+ "7. ERROR in Y.java (at line 23)\n" + >+ " c(new C());\n" + >+ " ^\n" + >+ "The method c(C) is ambiguous for the type D\n" + >+ "----------\n" + >+ "8. ERROR in Y.java (at line 24)\n" + >+ " c(new D());\n" + >+ " ^\n" + >+ "The method c(C) is ambiguous for the type D\n" + >+ "----------\n" + >+ "9. WARNING in Y.java (at line 28)\n" + >+ " void a(I x) {}\n" + >+ " ^\n" + >+ "I is a raw type. References to generic type I<T> should be parameterized\n" + >+ "----------\n" + >+ "10. WARNING in Y.java (at line 33)\n" + >+ " class B2 extends A2 {}\n" + >+ " ^^\n" + >+ "A2 is a raw type. References to generic type A2<T> should be parameterized\n" + >+ "----------\n" + >+ "11. WARNING in Y.java (at line 34)\n" + >+ " class C2 extends B2 implements I {\n" + >+ " ^\n" + >+ "I is a raw type. References to generic type I<T> should be parameterized\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 206930
: 126344