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 80032 Details for
Bug 148046
[compiler][1.5] should raise an incompatible types error when a given type variable cannot fulfill its bounds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
148046.txt (text/plain), 4.86 KB, created by
Philipe Mulet
on 2007-10-10 07:26:02 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2007-10-10 07:26:02 EDT
Size:
4.86 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java,v >retrieving revision 1.89 >diff -u -r1.89 TypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 9 Oct 2007 20:30:15 -0000 1.89 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 10 Oct 2007 11:25:32 -0000 >@@ -626,12 +626,16 @@ > break; > case Binding.TYPE_PARAMETER : > final TypeVariableBinding variable = (TypeVariableBinding) this; >- if (variable.firstBound == null) // unbound variable >- return false; > if (variable.isCapture()) { >- upperBound1 = variable.upperBound(); >+ CaptureBinding capture = (CaptureBinding) variable; >+ lowerBound1 = capture.lowerBound; >+ if (lowerBound1 == null) { >+ upperBound1 = capture.upperBound(); >+ } > break; > } >+ if (variable.firstBound == null) // unbound variable >+ return false; > TypeBinding eliminatedType = (paramType.environment.convertEliminatingTypeVariables(variable, paramType.genericType(), rank, null)); > switch (eliminatedType.kind()) { > case Binding.WILDCARD_TYPE : >@@ -671,12 +675,16 @@ > break; > case Binding.TYPE_PARAMETER : > TypeVariableBinding otherVariable = (TypeVariableBinding) otherArgument; >- if (otherVariable.firstBound == null) // unbound variable >- return false; > if (otherVariable.isCapture()) { >- upperBound2 = otherVariable.upperBound(); // TODO need to improve for otherBounds >+ CaptureBinding otherCapture = (CaptureBinding) otherVariable; >+ lowerBound2 = otherCapture.lowerBound; >+ if (lowerBound2 == null) { >+ upperBound2 = otherCapture.upperBound(); >+ } > break; >- } >+ } >+ if (otherVariable.firstBound == null) // unbound variable >+ return false; > TypeBinding otherEliminatedType = (paramType.environment.convertEliminatingTypeVariables(otherVariable, paramType.genericType(), rank, null)); > switch (otherEliminatedType.kind()) { > case Binding.WILDCARD_TYPE : >@@ -701,15 +709,12 @@ > > } else if (upperBound2 != null) { > return !lowerBound1.isCompatibleWith(upperBound2); >-// return lowerBound1.isProvableDistinctSubType(upperBound2); > } else { > return !lowerBound1.isCompatibleWith(otherArgument); >-// return lowerBound1.isProvableDistinctSubType(otherArgument); > } > } else if (upperBound1 != null) { > if (lowerBound2 != null) { > return !lowerBound2.isCompatibleWith(upperBound1); >- //return lowerBound2.isProvableDistinctSubType(upperBound1); > } else if (upperBound2 != null) { > return upperBound1.isProvableDistinctSubType(upperBound2) > && upperBound2.isProvableDistinctSubType(upperBound1); >@@ -719,7 +724,6 @@ > } else { > if (lowerBound2 != null) { > return !lowerBound2.isCompatibleWith(this); >-// return lowerBound2.isProvableDistinctSubType(this); > } else if (upperBound2 != null) { > return this.isProvableDistinctSubType(upperBound2); > } else { >#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.653 >diff -u -r1.653 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 9 Oct 2007 21:05:13 -0000 1.653 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 10 Oct 2007 11:25:39 -0000 >@@ -39814,4 +39814,30 @@ > "Unnecessary cast from List<Object> to ArrayList<? extends String>\n" + > "----------\n"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=148046 >+public void test1193() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class A {}\n" + >+ "class B extends A {}\n" + >+ "public class X<T> {\n" + >+ " public <U extends B> void foo(X<? super A> param) {\n" + >+ " X<U> foo = (X<U>) param; // unchecked warning vs error\n" + >+ " X<B> bar = (X<B>) param; // unchecked warning vs error\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " X<U> foo = (X<U>) param; // unchecked warning vs error\n" + >+ " ^^^^^^^^^^^^\n" + >+ "Cannot cast from X<capture#1-of ? super A> to X<U>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 6)\n" + >+ " X<B> bar = (X<B>) param; // unchecked warning vs error\n" + >+ " ^^^^^^^^^^^^\n" + >+ "Cannot cast from X<capture#2-of ? super A> to X<B>\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 148046
:
80032
|
80034
|
80043