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 130461 Details for
Bug 159851
[1.5] [compiler] Eclipse compiler fails to report type parameter bounds errors when generic instance is a type argument
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch and testcase
patch.txt (text/plain), 9.63 KB, created by
Kent Johnson
on 2009-03-31 16:35:15 EDT
(
hide
)
Description:
Proposed patch and testcase
Filename:
MIME Type:
Creator:
Kent Johnson
Created:
2009-03-31 16:35:15 EDT
Size:
9.63 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v >retrieving revision 1.793 >diff -u -r1.793 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 25 Mar 2009 20:17:48 -0000 1.793 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 31 Mar 2009 20:34:02 -0000 >@@ -49455,4 +49455,81 @@ > "" > ); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=159851 >+public void test1450() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.util.*;\n" + >+ "class A {}\n" + >+ "class B<T extends A> {}\n" + >+ "class X<T extends ArrayList<B<Integer>>> extends TreeMap<Integer, B<String>> {}\n" + >+ "\n" + >+ "class D<T> {}\n" + >+ "class E<T extends Number> {}\n" + >+ "class Y<T> extends E<D<T>> {}", >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " class X<T extends ArrayList<B<Integer>>> extends TreeMap<Integer, B<String>> {}\n" + >+ " ^\n" + >+ "The serializable class X does not declare a static final serialVersionUID field of type long\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " class X<T extends ArrayList<B<Integer>>> extends TreeMap<Integer, B<String>> {}\n" + >+ " ^^^^^^^\n" + >+ "Bound mismatch: The type Integer is not a valid substitute for the bounded parameter <T extends A> of the type B<T>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 4)\n" + >+ " class X<T extends ArrayList<B<Integer>>> extends TreeMap<Integer, B<String>> {}\n" + >+ " ^^^^^^\n" + >+ "Bound mismatch: The type String is not a valid substitute for the bounded parameter <T extends A> of the type B<T>\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 8)\n" + >+ " class Y<T> extends E<D<T>> {}\n" + >+ " ^\n" + >+ "Bound mismatch: The type D<T> is not a valid substitute for the bounded parameter <T extends Number> of the type E<T>\n" + >+ "----------\n" >+ ); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=159851 >+public void test1451() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class A<T> {}\n" + >+ "class B<T2 extends Number> {}\n" + >+ "class C<T3, T4> {}\n" + >+ "class X<T1, T2> extends C<A<A<B<T1>>>, A<B<T2>>> {}\n" + >+ "class Y<T> extends A<A<B<T>>> {}\n" + >+ "class Z<T> extends C<B<T>, A<B<T>>> {}", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " class X<T1, T2> extends C<A<A<B<T1>>>, A<B<T2>>> {}\n" + >+ " ^^\n" + >+ "Bound mismatch: The type T1 is not a valid substitute for the bounded parameter <T2 extends Number> of the type B<T2>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " class X<T1, T2> extends C<A<A<B<T1>>>, A<B<T2>>> {}\n" + >+ " ^^\n" + >+ "Bound mismatch: The type T2 is not a valid substitute for the bounded parameter <T2 extends Number> of the type B<T2>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 5)\n" + >+ " class Y<T> extends A<A<B<T>>> {}\n" + >+ " ^\n" + >+ "Bound mismatch: The type T is not a valid substitute for the bounded parameter <T2 extends Number> of the type B<T2>\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 6)\n" + >+ " class Z<T> extends C<B<T>, A<B<T>>> {}\n" + >+ " ^\n" + >+ "Bound mismatch: The type T is not a valid substitute for the bounded parameter <T2 extends Number> of the type B<T2>\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 6)\n" + >+ " class Z<T> extends C<B<T>, A<B<T>>> {}\n" + >+ " ^\n" + >+ "Bound mismatch: The type T is not a valid substitute for the bounded parameter <T2 extends Number> of the type B<T2>\n" + >+ "----------\n" >+ ); >+} > } >\ No newline at end of file >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java,v >retrieving revision 1.49 >diff -u -r1.49 ParameterizedSingleTypeReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 8 Dec 2008 14:19:29 -0000 1.49 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 31 Mar 2009 20:34:04 -0000 >@@ -231,9 +231,10 @@ > > ParameterizedTypeBinding parameterizedType = scope.environment().createParameterizedType(currentOriginal, argTypes, enclosingType); > // check argument type compatibility >- if (checkBounds) { // otherwise will do it in Scope.connectTypeVariables() or generic method resolution >+ if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution > parameterizedType.boundCheck(scope, this.typeArguments); >- } >+ else >+ scope.rememberTypeReference(this); > if (isTypeUseDeprecated(parameterizedType, scope)) > reportDeprecatedType(parameterizedType, scope); > >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java,v >retrieving revision 1.53 >diff -u -r1.53 ParameterizedQualifiedTypeReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java 8 Dec 2008 14:19:29 -0000 1.53 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java 31 Mar 2009 20:34:04 -0000 >@@ -261,6 +261,8 @@ > // check argument type compatibility > if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution > parameterizedType.boundCheck(scope, args); >+ else >+ scope.rememberTypeReference(this); > qualifyingType = parameterizedType; > } else { > ReferenceBinding currentOriginal = (ReferenceBinding)currentType.original(); >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.353 >diff -u -r1.353 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 27 Mar 2009 19:33:56 -0000 1.353 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 31 Mar 2009 20:34:04 -0000 >@@ -3907,6 +3907,18 @@ > return null; > } > >+ public void rememberTypeReference(TypeReference typeRef) { >+ if (this.kind == CLASS_SCOPE) { >+ ClassScope classScope = (ClassScope) this; >+ if (classScope.typeReferences == null) { >+ classScope.typeReferences = new ArrayList(3); >+ classScope.typeReferences.add(typeRef); >+ } else if (!classScope.typeReferences.contains(typeRef)) { >+ classScope.typeReferences.add(typeRef); >+ } >+ } >+ } >+ > // start position in this scope - for ordering scopes vs. variables > int startIndex() { > return 0; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java,v >retrieving revision 1.170 >diff -u -r1.170 ClassScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 30 Mar 2009 06:24:30 -0000 1.170 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 31 Mar 2009 20:34:04 -0000 >@@ -32,10 +32,12 @@ > > public TypeDeclaration referenceContext; > public TypeReference superTypeReference; >+ java.util.ArrayList typeReferences; > > public ClassScope(Scope parent, TypeDeclaration context) { > super(Scope.CLASS_SCOPE, parent); > this.referenceContext = context; >+ this.typeReferences = null; // initialized if required > } > > void buildAnonymousTypeBinding(SourceTypeBinding enclosingType, ReferenceBinding supertype) { >@@ -813,19 +815,9 @@ > > // Perform deferred bound checks for parameterized type references (only done after hierarchy is connected) > public void checkParameterizedTypeBounds() { >- TypeReference superclass = this.referenceContext.superclass; >- if (superclass != null) >- superclass.checkBounds(this); >- >- TypeReference[] superinterfaces = this.referenceContext.superInterfaces; >- if (superinterfaces != null) >- for (int i = 0, length = superinterfaces.length; i < length; i++) >- superinterfaces[i].checkBounds(this); >- >- TypeParameter[] typeParameters = this.referenceContext.typeParameters; >- if (typeParameters != null) >- for (int i = 0, paramLength = typeParameters.length; i < paramLength; i++) >- typeParameters[i].checkBounds(this); >+ for (int i = 0, l = this.typeReferences == null ? 0 : this.typeReferences.size(); i < l; i++) >+ ((TypeReference) this.typeReferences.get(i)).checkBounds(this); >+ this.typeReferences = null; > > ReferenceBinding[] memberTypes = this.referenceContext.binding.memberTypes; > if (memberTypes != null && memberTypes != Binding.NO_MEMBER_TYPES)
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 159851
:
130282
| 130461