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 79958 Details for
Bug 158870
[1.5][compiler] javac inconvertible types on cast allowed by Eclipse
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
158870a.txt (text/plain), 51.42 KB, created by
Philipe Mulet
on 2007-10-09 10:49:40 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2007-10-09 10:49:40 EDT
Size:
51.42 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.650 >diff -u -r1.650 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 28 Sep 2007 18:26:13 -0000 1.650 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 9 Oct 2007 14:48:48 -0000 >@@ -17953,14 +17953,14 @@ > this.runNegativeTest( > new String[] { > "X.java", >- "public class X<S extends Comparable<S>> {\n" + >- " public void f() {\n" + >- " Class<S> currentClass = null;\n" + >- " boolean b = currentClass == Long.class;\n" + // not provably distinct types >- " \n" + >- " boolean c = X.class == Long.class;\n" + // provably distinct types >- " }\n" + >- "}\n", >+ "public class X<S extends Comparable<S>> {\n" + >+ " public void f() {\n" + >+ " Class<? extends Comparable<?>> cc = Long.class;\n" + >+ " Class<S> currentClass = null;\n" + >+ " boolean b = currentClass == Long.class;\n" + >+ " boolean c = X.class == Long.class;\n" + >+ " }\n" + >+ "}\n", > }, > "----------\n" + > "1. ERROR in X.java (at line 6)\n" + >@@ -18581,7 +18581,7 @@ > ""); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=89940 >- public void _test0610() { >+ public void test0610() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -18601,27 +18601,32 @@ > " }\n" + > "}\n", > }, >- "----------\n" + >- "1. ERROR in X.java (at line 9)\n" + >- " numbers= (List<Number>) objects; // correct - cast error\n" + >- " ^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Cannot cast from List<Object> to List<Number>\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 10)\n" + >- " ext= (List<? extends Number>) objects; // wrong, should fail\n" + >- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Cannot cast from List<Object> to List<? extends Number>\n" + >- "----------\n" + >- "3. WARNING in X.java (at line 12)\n" + >- " ext= raw; // correct - raw conversion warning issued\n" + >- " ^^^\n" + >- "Type safety: The expression of type List needs unchecked conversion to conform to List<? extends Number>\n" + >- "----------\n" + >- "4. WARNING in X.java (at line 13)\n" + >- " numbers= raw; // correct - raw conversion warning issued\n" + >- " ^^^\n" + >- "Type safety: The expression of type List needs unchecked conversion to conform to List<Number>\n" + >- "----------\n"); >+ "----------\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " void foo(List<Object> objects, List raw) {\n" + >+ " ^^^^\n" + >+ "List is a raw type. References to generic type List<E> should be parameterized\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 9)\n" + >+ " numbers= (List<Number>) objects; // correct - cast error\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Cannot cast from List<Object> to List<Number>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 10)\n" + >+ " ext= (List<? extends Number>) objects; // wrong, should fail\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Cannot cast from List<Object> to List<? extends Number>\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 12)\n" + >+ " ext= raw; // correct - raw conversion warning issued\n" + >+ " ^^^\n" + >+ "Type safety: The expression of type List needs unchecked conversion to conform to List<? extends Number>\n" + >+ "----------\n" + >+ "5. WARNING in X.java (at line 13)\n" + >+ " numbers= raw; // correct - raw conversion warning issued\n" + >+ " ^^^\n" + >+ "Type safety: The expression of type List needs unchecked conversion to conform to List<Number>\n" + >+ "----------\n"); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=91696 > public void test0611() { >@@ -20482,10 +20487,10 @@ > " ^^^^^^^^^^^^^^^^^^^^^^\n" + > "Cannot cast from List<Object> to List<Number>\n" + > "----------\n" + >- "3. WARNING in X.java (at line 10)\n" + >+ "3. ERROR in X.java (at line 10)\n" + > " ext= (List<? extends Number>) objects; // wrong, should fail\n" + > " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Type safety: Unchecked cast from List<Object> to List<? extends Number>\n" + >+ "Cannot cast from List<Object> to List<? extends Number>\n" + > "----------\n" + > "4. WARNING in X.java (at line 12)\n" + > " ext= raw; // correct - raw conversion warning issued\n" + >@@ -22769,25 +22774,12 @@ > " private SuperInterface< ? extends SuperInterface> x = null;\n" + > " ^^^^^^^^^^^^^^\n" + > "X.SuperInterface is a raw type. References to generic type X.SuperInterface<A> should be parameterized\n" + >- "----------\n" >- //TODO should be >-// "----------\n" + >-// "1. ERROR in X.java (at line 3)\n" + >-// " Zork z;\n" + >-// " ^^^^\n" + >-// "Zork cannot be resolved to a type\n" + >-// "----------\n" + >-// "2. WARNING in X.java (at line 11)\n" + >-// " private SuperInterface< ? extends SuperInterface> x = null;\n" + >-// " ^^^^^^^^^^^^^^\n" + >-// "X.SuperInterface is a raw type. References to generic type X.SuperInterface<A> should be parameterized\n" + >-// "----------\n" + >-// "3. ERROR in X.java (at line 14)\n" + >-// " ((SubInterface) this.x).getString();\n" + >-// " ^^^^^^^^^^^^^^^^^^^^^^^\n" + >-// "Cannot cast from X.SuperInterface<capture#1-of ? extends X.SuperInterface> to X.SubInterface\n" + >-// "----------\n" >- ); >+ "----------\n" + >+ "3. ERROR in X.java (at line 14)\n" + >+ " ((SubInterface) this.x).getString();\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Cannot cast from X.SuperInterface<capture#1-of ? extends X.SuperInterface> to X.SubInterface\n" + >+ "----------\n" ); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=97440 > public void test0731() { >@@ -26540,10 +26532,10 @@ > " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + > "Unnecessary cast from List<Object&Serializable&CharSequence> to List<? extends CharSequence>\n" + > "----------\n" + >- "2. WARNING in X.java (at line 12)\n" + >+ "2. ERROR in X.java (at line 12)\n" + > " Object result4 = (List<? extends String>)merge(list1, list2);\n" + > " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Type safety: Unchecked cast from List<Object&Serializable&CharSequence> to List<? extends String>\n" + >+ "Cannot cast from List<Object&Serializable&CharSequence> to List<? extends String>\n" + > "----------\n" + > "3. WARNING in X.java (at line 12)\n" + > " Object result4 = (List<? extends String>)merge(list1, list2);\n" + >@@ -30778,10 +30770,10 @@ > "}\n" > }, > "----------\n" + >- "1. WARNING in X.java (at line 2)\n" + >+ "1. ERROR in X.java (at line 2)\n" + > " protected static final Class<X<?>> theClass = (Class<X<?>>) X.class;\n" + > " ^^^^^^^^^^^^^^^^^^^^^\n" + >- "Type safety: Unchecked cast from Class<X> to Class<X<?>>\n" + >+ "Cannot cast from Class<X> to Class<X<?>>\n" + > "----------\n" + > "2. WARNING in X.java (at line 3)\n" + > " void foo(Class<X> cx) {\n" + >@@ -30793,10 +30785,10 @@ > " ^^\n" + > "Type mismatch: cannot convert from Class<X> to Class<X<?>>\n" + > "----------\n" + >- "4. WARNING in X.java (at line 5)\n" + >+ "4. ERROR in X.java (at line 5)\n" + > " Class<X<?>> cx2 = (Class<X<?>>) cx;\n" + > " ^^^^^^^^^^^^^^^^\n" + >- "Type safety: Unchecked cast from Class<X> to Class<X<?>>\n" + >+ "Cannot cast from Class<X> to Class<X<?>>\n" + > "----------\n"); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=115918 >@@ -35890,7 +35882,7 @@ > } > > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158870 >-public void _test1084() { >+public void test1084() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -35906,7 +35898,22 @@ > " }\n" + > "}", > }, >- "ERR"); >+ "----------\n" + >+ "1. WARNING in X.java (at line 8)\n" + >+ " Z<Y> l2 = (Z<Y>) l1;\n" + >+ " ^\n" + >+ "Y is a raw type. References to generic type Y<T> should be parameterized\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 8)\n" + >+ " Z<Y> l2 = (Z<Y>) l1;\n" + >+ " ^^^^^^^^^\n" + >+ "Cannot cast from Z<Y<?>> to Z<Y>\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 8)\n" + >+ " Z<Y> l2 = (Z<Y>) l1;\n" + >+ " ^\n" + >+ "Y is a raw type. References to generic type Y<T> should be parameterized\n" + >+ "----------\n"); > } > > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=165291 >@@ -39581,4 +39588,169 @@ > "Duplicate method foo2(Class<X<U,V>>) in type X<U,V>\n" + > "----------\n"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=158870 - variation >+public void test1186() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.io.Serializable;\n" + >+ "\n" + >+ "public class X<T> {\n" + >+ " void foo1(X<? extends String> x1, X<? extends Number> x2) {\n" + >+ " x1 = (X<? extends String>) x2;\n" + >+ " }\n" + >+ " void foo2(X<? extends String> x1, X<? extends Runnable> x2) {\n" + >+ " x1 = (X<? extends String>) x2;\n" + >+ " } \n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " x1 = (X<? extends String>) x2;\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Cannot cast from X<capture#2-of ? extends Number> to X<? extends String>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 8)\n" + >+ " x1 = (X<? extends String>) x2;\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Cannot cast from X<capture#5-of ? extends Runnable> to X<? extends String>\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=158870 - variation >+public void test1187() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.io.Serializable;\n" + >+ "public class X<T> {\n" + >+ " void foo3(X<? extends Serializable> x1, X<? extends Runnable> x2) {\n" + >+ " x1 = (X<? extends Serializable>) x2;\n" + >+ " } \n" + >+ " void foo4(X<? extends Runnable> x1, X<? extends String> x2) {\n" + >+ " x1 = (X<? extends Runnable>) x2;\n" + >+ " } \n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " x1 = (X<? extends Serializable>) x2;\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type safety: Unchecked cast from X<capture#2-of ? extends Runnable> to X<? extends Serializable>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 7)\n" + >+ " x1 = (X<? extends Runnable>) x2;\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Cannot cast from X<capture#5-of ? extends String> to X<? extends Runnable>\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=158870 - variation >+public void test1188() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " <T extends String, S extends Comparable<T>> void foo(Integer i) {\n" + >+ " S a = (S) i; // error?\n" + >+ " }\n" + >+ " <U extends Comparable<U>> void bar(Integer i) {\n" + >+ " U a = (U) i; // unchecked?\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 2)\n" + >+ " <T extends String, S extends Comparable<T>> void foo(Integer i) {\n" + >+ " ^^^^^^\n" + >+ "The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " S a = (S) i; // error?\n" + >+ " ^^^^^\n" + >+ "Cannot cast from Integer to S\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 6)\n" + >+ " U a = (U) i; // unchecked?\n" + >+ " ^^^^^\n" + >+ "Type safety: Unchecked cast from Integer to U\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=158870 - variation >+public void test1189() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " <T extends String, S extends Comparable<T>> void foo(Number n) {\n" + >+ " S a = (S) n; // unchecked?\n" + >+ " }\n" + >+ " <U extends Comparable<U>> void bar(Number n) {\n" + >+ " U a = (U) n; // unchecked?\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 2)\n" + >+ " <T extends String, S extends Comparable<T>> void foo(Number n) {\n" + >+ " ^^^^^^\n" + >+ "The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 3)\n" + >+ " S a = (S) n; // unchecked?\n" + >+ " ^^^^^\n" + >+ "Type safety: Unchecked cast from Number to S\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 6)\n" + >+ " U a = (U) n; // unchecked?\n" + >+ " ^^^^^\n" + >+ "Type safety: Unchecked cast from Number to U\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=158870 - variation >+public void test1190() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " <U extends Integer, T extends U, S extends Comparable<T>> void foo2(Integer i) {\n" + >+ " S a = (S) i; // unchecked1?\n" + >+ " Comparable<T> b = (Comparable<T>) i; // unchecked2?\n" + >+ " } \n" + >+ " <U extends String, T extends U, S extends Comparable<T>> void foo3(Integer i) {\n" + >+ " S a = (S) i; // error?\n" + >+ " Comparable<T> b = (Comparable<T>) i; // error3?\n" + >+ " } \n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 2)\n" + >+ " <U extends Integer, T extends U, S extends Comparable<T>> void foo2(Integer i) {\n" + >+ " ^^^^^^^\n" + >+ "The type parameter U should not be bounded by the final type Integer. Final types cannot be further extended\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 3)\n" + >+ " S a = (S) i; // unchecked1?\n" + >+ " ^^^^^\n" + >+ "Type safety: Unchecked cast from Integer to S\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 4)\n" + >+ " Comparable<T> b = (Comparable<T>) i; // unchecked2?\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Type safety: Unchecked cast from Integer to Comparable<T>\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 6)\n" + >+ " <U extends String, T extends U, S extends Comparable<T>> void foo3(Integer i) {\n" + >+ " ^^^^^^\n" + >+ "The type parameter U should not be bounded by the final type String. Final types cannot be further extended\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 7)\n" + >+ " S a = (S) i; // error?\n" + >+ " ^^^^^\n" + >+ "Cannot cast from Integer to S\n" + >+ "----------\n" + >+ "6. ERROR in X.java (at line 8)\n" + >+ " Comparable<T> b = (Comparable<T>) i; // error3?\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Cannot cast from Integer to Comparable<T>\n" + >+ "----------\n"); >+} > } >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java,v >retrieving revision 1.98 >diff -u -r1.98 ParameterizedTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 24 Sep 2007 22:49:54 -0000 1.98 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 9 Oct 2007 14:48:52 -0000 >@@ -688,73 +688,6 @@ > return false; > } > >- public boolean isIntersectingWith(TypeBinding otherType) { >- if (this == otherType) >- return true; >- if (otherType == null) >- return false; >- switch(otherType.kind()) { >- >- case Binding.PARAMETERIZED_TYPE : >- ParameterizedTypeBinding otherParamType = (ParameterizedTypeBinding) otherType; >- if (this.type != otherParamType.type) >- return false; >- if (!isStatic()) { // static member types do not compare their enclosing >- ReferenceBinding enclosing = enclosingType(); >- if (enclosing != null) { >- ReferenceBinding otherEnclosing = otherParamType.enclosingType(); >- if (otherEnclosing == null) return false; >- if ((otherEnclosing.tagBits & TagBits.HasDirectWildcard) == 0) { >- if (enclosing != otherEnclosing) return false; >- } else { >- if (!enclosing.isEquivalentTo(otherParamType.enclosingType())) return false; >- } >- } >- } >- int length = this.arguments == null ? 0 : this.arguments.length; >- TypeBinding[] otherArguments = otherParamType.arguments; >- int otherLength = otherArguments == null ? 0 : otherArguments.length; >- if (otherLength != length) >- return false; >- for (int i = 0; i < length; i++) { >- if (!this.arguments[i].isTypeArgumentIntersecting(otherArguments[i])) >- return false; >- } >- return true; >- >- case Binding.GENERIC_TYPE : >- SourceTypeBinding otherGenericType = (SourceTypeBinding) otherType; >- if (this.type != otherGenericType) >- return false; >- if (!isStatic()) { // static member types do not compare their enclosing >- ReferenceBinding enclosing = enclosingType(); >- if (enclosing != null) { >- ReferenceBinding otherEnclosing = otherGenericType.enclosingType(); >- if (otherEnclosing == null) return false; >- if ((otherEnclosing.tagBits & TagBits.HasDirectWildcard) == 0) { >- if (enclosing != otherEnclosing) return false; >- } else { >- if (!enclosing.isEquivalentTo(otherGenericType.enclosingType())) return false; >- } >- } >- } >- length = this.arguments == null ? 0 : this.arguments.length; >- otherArguments = otherGenericType.typeVariables(); >- otherLength = otherArguments == null ? 0 : otherArguments.length; >- if (otherLength != length) >- return false; >- for (int i = 0; i < length; i++) { >- if (!this.arguments[i].isTypeArgumentIntersecting(otherArguments[i])) >- return false; >- } >- return true; >- >- case Binding.RAW_TYPE : >- return erasure() == otherType.erasure(); >- } >- return false; >- } >- > /** > * @see org.eclipse.jdt.internal.compiler.lookup.TypeBinding#isParameterizedType() > */ >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.315 >diff -u -r1.315 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 26 Sep 2007 19:11:33 -0000 1.315 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 9 Oct 2007 14:48:55 -0000 >@@ -58,6 +58,7 @@ > return Scope.MORE_GENERIC; > return Scope.NOT_RELATED; > } >+ > public static TypeBinding getBaseType(char[] name) { > // list should be optimized (with most often used first) > int length = name.length; >@@ -246,18 +247,6 @@ > substitutedArguments = substitute(substitution, originalArguments); > } > if (substitutedArguments != originalArguments || substitutedEnclosing != originalEnclosing) { >-// identicalVariables: { // if substituted with original variables, then answer the generic type itself >-// if (substitutedEnclosing != null) { >-// //if (!(substitutedEnclosing instanceof SourceTypeBinding)) break identicalVariables; >-// if (substitutedEnclosing != originalEnclosing) break identicalVariables; >-// } >-// if (originalParameterizedType.type.isBinaryBinding()) break identicalVariables; // generic binary is never used as is, see 85262 >-// TypeVariableBinding[] originalVariables = originalParameterizedType.type.typeVariables(); >-// for (int i = 0, length = originalVariables.length; i < length; i++) { >-// if (substitutedArguments[i] != originalVariables[i]) break identicalVariables; >-// } >-// return originalParameterizedType.type; >-// } > return originalParameterizedType.environment.createParameterizedType( > originalParameterizedType.genericType(), substitutedArguments, substitutedEnclosing); > } >@@ -316,10 +305,7 @@ > // treat as if parameterized with its type variables (non generic type gets 'null' arguments) > originalArguments = originalReferenceType.typeVariables(); > substitutedArguments = substitute(substitution, originalArguments); >-// if (substitutedArguments != originalArguments || substitutedEnclosing != originalEnclosing) { > return substitution.environment().createParameterizedType(originalReferenceType, substitutedArguments, substitutedEnclosing); >-// } >-// break; > } > return originalType; > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java,v >retrieving revision 1.87 >diff -u -r1.87 LookupEnvironment.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 24 Sep 2007 22:49:54 -0000 1.87 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 9 Oct 2007 14:48:52 -0000 >@@ -415,6 +415,118 @@ > return originalType; > } > >+public TypeBinding convertEliminatingTypeVariables(TypeBinding originalType, ReferenceBinding genericType, int rank, TypeVariableBinding eliminatedVariable) { >+ if ((originalType.tagBits & TagBits.HasTypeVariable) != 0) { >+ switch (originalType.kind()) { >+ case Binding.ARRAY_TYPE : >+ ArrayBinding originalArrayType = (ArrayBinding) originalType; >+ TypeBinding originalLeafComponentType = originalArrayType.leafComponentType; >+ TypeBinding substitute = convertEliminatingTypeVariables(originalLeafComponentType, genericType, rank, eliminatedVariable); // substitute could itself be array type >+ if (substitute != originalLeafComponentType) { >+ return createArrayType(substitute.leafComponentType(), substitute.dimensions() + originalArrayType.dimensions()); >+ } >+ break; >+ case Binding.PARAMETERIZED_TYPE : >+ ParameterizedTypeBinding paramType = (ParameterizedTypeBinding) originalType; >+ ReferenceBinding originalEnclosing = paramType.enclosingType(); >+ ReferenceBinding substitutedEnclosing = originalEnclosing; >+ if (originalEnclosing != null) { >+ substitutedEnclosing = (ReferenceBinding) convertEliminatingTypeVariables(originalEnclosing, genericType, rank, eliminatedVariable); >+ } >+ TypeBinding[] originalArguments = paramType.arguments; >+ TypeBinding[] substitutedArguments = originalArguments; >+ for (int i = 0, length = originalArguments == null ? 0 : originalArguments.length; i < length; i++) { >+ TypeBinding originalArgument = originalArguments[i]; >+ TypeBinding substitutedArgument = convertEliminatingTypeVariables(originalArgument, paramType.genericType(), i, eliminatedVariable); >+ if (substitutedArgument != originalArgument) { >+ if (substitutedArguments == originalArguments) { >+ System.arraycopy(originalArguments, 0, substitutedArguments = new TypeBinding[length], 0, i); >+ } >+ substitutedArguments[i] = substitutedArgument; >+ } else if (substitutedArguments != originalArguments) { >+ substitutedArguments[i] = originalArgument; >+ } >+ } >+ if (originalEnclosing != substitutedEnclosing || originalArguments != substitutedArguments) { >+ return createParameterizedType(paramType.genericType(), substitutedArguments, substitutedEnclosing); >+ } >+ break; >+ case Binding.TYPE_PARAMETER : >+ if (eliminatedVariable == originalType) { >+ return createWildcard(genericType, rank, null, null, Wildcard.UNBOUND); >+ } >+ TypeVariableBinding variable = (TypeVariableBinding) originalType; >+ TypeBinding originalUpperBound = variable.upperBound(); >+ TypeBinding substitutedUpperBound = convertEliminatingTypeVariables(originalUpperBound, genericType, rank, variable); >+ return createWildcard(genericType, rank, substitutedUpperBound, null, Wildcard.EXTENDS); >+ case Binding.RAW_TYPE : >+ break; >+ case Binding.GENERIC_TYPE : >+ ReferenceBinding currentType = (ReferenceBinding) originalType; >+ originalEnclosing = currentType.enclosingType(); >+ substitutedEnclosing = originalEnclosing; >+ if (originalEnclosing != null) { >+ substitutedEnclosing = (ReferenceBinding) convertEliminatingTypeVariables(originalEnclosing, genericType, rank, eliminatedVariable); >+ } >+ originalArguments = currentType.typeVariables(); >+ substitutedArguments = originalArguments; >+ for (int i = 0, length = originalArguments == null ? 0 : originalArguments.length; i < length; i++) { >+ TypeBinding originalArgument = originalArguments[i]; >+ TypeBinding substitutedArgument = convertEliminatingTypeVariables(originalArgument, currentType, i, eliminatedVariable); >+ if (substitutedArgument != originalArgument) { >+ if (substitutedArguments == originalArguments) { >+ System.arraycopy(originalArguments, 0, substitutedArguments = new TypeBinding[length], 0, i); >+ } >+ substitutedArguments[i] = substitutedArgument; >+ } else if (substitutedArguments != originalArguments) { >+ substitutedArguments[i] = originalArgument; >+ } >+ } >+ if (originalEnclosing != substitutedEnclosing || originalArguments != substitutedArguments) { >+ return createParameterizedType(genericType, substitutedArguments, substitutedEnclosing); >+ } >+ break; >+ case Binding.WILDCARD_TYPE : >+ WildcardBinding wildcard = (WildcardBinding) originalType; >+ TypeBinding originalBound = wildcard.bound; >+ TypeBinding substitutedBound = originalBound; >+ if (originalBound != null) { >+ substitutedBound = convertEliminatingTypeVariables(originalBound, genericType, rank, eliminatedVariable); >+ if (substitutedBound != originalBound) { >+ return createWildcard(wildcard.genericType, wildcard.rank, substitutedBound, null, wildcard.boundKind); >+ } >+ } >+ break; >+ case Binding.INTERSECTION_TYPE : >+ WildcardBinding intersection = (WildcardBinding) originalType; >+ originalBound = intersection.bound; >+ substitutedBound = originalBound; >+ if (originalBound != null) { >+ substitutedBound = convertEliminatingTypeVariables(originalBound, genericType, rank, eliminatedVariable); >+ } >+ TypeBinding[] originalOtherBounds = intersection.otherBounds; >+ TypeBinding[] substitutedOtherBounds = originalOtherBounds; >+ for (int i = 0, length = originalOtherBounds == null ? 0 : originalOtherBounds.length; i < length; i++) { >+ TypeBinding originalOtherBound = originalOtherBounds[i]; >+ TypeBinding substitutedOtherBound = convertEliminatingTypeVariables(originalOtherBound, genericType, rank, eliminatedVariable); >+ if (substitutedOtherBound != originalOtherBound) { >+ if (substitutedOtherBounds == originalOtherBounds) { >+ System.arraycopy(originalOtherBounds, 0, substitutedOtherBounds = new TypeBinding[length], 0, i); >+ } >+ substitutedOtherBounds[i] = substitutedOtherBound; >+ } else if (substitutedOtherBounds != originalOtherBounds) { >+ substitutedOtherBounds[i] = originalOtherBound; >+ } >+ } >+ if (substitutedBound != originalBound || substitutedOtherBounds != originalOtherBounds) { >+ return createWildcard(intersection.genericType, intersection.rank, substitutedBound, substitutedOtherBounds, intersection.boundKind); >+ } >+ break; >+ } >+ } >+ return originalType; >+} >+ > public TypeBinding convertToRawType(TypeBinding type) { > int dimension; > TypeBinding originalType; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java,v >retrieving revision 1.34 >diff -u -r1.34 RawTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java 24 Sep 2007 22:49:54 -0000 1.34 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java 9 Oct 2007 14:48:52 -0000 >@@ -123,19 +123,19 @@ > return false; > } > >- public boolean isIntersectingWith(TypeBinding otherType) { >+ public boolean isProvablyDistinct(TypeBinding otherType) { > if (this == otherType) >- return true; >+ return false; > if (otherType == null) >- return false; >+ return true; > switch(otherType.kind()) { > > case Binding.GENERIC_TYPE : > case Binding.PARAMETERIZED_TYPE : > case Binding.RAW_TYPE : >- return erasure() == otherType.erasure(); >+ return erasure() != otherType.erasure(); > } >- return false; >+ return true; > } > > /** >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.88 >diff -u -r1.88 TypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 24 Sep 2007 22:49:54 -0000 1.88 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 9 Oct 2007 14:48:55 -0000 >@@ -418,13 +418,6 @@ > } > > /** >- * Returns true if a type is intersecting with another one, >- */ >-public boolean isIntersectingWith(TypeBinding otherType) { >- return this == otherType; >-} >- >-/** > * Returns true if the current type denotes an intersection type: Number & Comparable<?> > */ > public boolean isIntersectionType() { >@@ -487,11 +480,258 @@ > return true; > } > >-public boolean isRawType() { >+private boolean isProvableDistinctSubType(TypeBinding otherType) { >+ if (otherType.isInterface()) { >+ if (this.isInterface()) >+ return false; >+ if (this.isArrayType() >+ || ((this instanceof ReferenceBinding) && ((ReferenceBinding) this).isFinal()) >+ || (this.isTypeVariable() && ((TypeVariableBinding)this).superclass().isFinal())) { >+ return !this.isCompatibleWith(otherType); >+ } >+ return false; >+ } else { >+ if (this.isInterface()) { >+ if (otherType.isArrayType() >+ || ((otherType instanceof ReferenceBinding) && ((ReferenceBinding) otherType).isFinal()) >+ || (otherType.isTypeVariable() && ((TypeVariableBinding)otherType).superclass().isFinal())) { >+ return !this.isCompatibleWith(otherType); >+ } >+ } else { >+ if (!this.isTypeVariable() && !otherType.isTypeVariable()) { >+ return !this.isCompatibleWith(otherType); >+ } >+ } >+ } > return false; > } > > /** >+ * Returns true if a type is provably distinct from another one, >+ */ >+public boolean isProvablyDistinct(TypeBinding otherType) { >+ if (this == otherType) >+ return false; >+ if (otherType == null) >+ return true; >+ >+ switch (kind()) { >+ >+ case Binding.PARAMETERIZED_TYPE : >+ ParameterizedTypeBinding paramType = (ParameterizedTypeBinding) this; >+ switch(otherType.kind()) { >+ case Binding.PARAMETERIZED_TYPE : >+ ParameterizedTypeBinding otherParamType = (ParameterizedTypeBinding) otherType; >+ if (paramType.genericType() != otherParamType.genericType()) >+ return true; >+ if (!paramType.isStatic()) { // static member types do not compare their enclosing >+ ReferenceBinding enclosing = enclosingType(); >+ if (enclosing != null) { >+ ReferenceBinding otherEnclosing = otherParamType.enclosingType(); >+ if (otherEnclosing == null) return true; >+ if ((otherEnclosing.tagBits & TagBits.HasDirectWildcard) == 0) { >+ if (enclosing != otherEnclosing) return true; >+ } else { >+ if (!enclosing.isEquivalentTo(otherParamType.enclosingType())) return true; >+ } >+ } >+ } >+ int length = paramType.arguments == null ? 0 : paramType.arguments.length; >+ TypeBinding[] otherArguments = otherParamType.arguments; >+ int otherLength = otherArguments == null ? 0 : otherArguments.length; >+ if (otherLength != length) >+ return true; >+ for (int i = 0; i < length; i++) { >+ if (paramType.arguments[i].isProvablyDistinctTypeArgument(otherArguments[i], paramType, i)) >+ return true; >+ } >+ return false; >+ >+ case Binding.GENERIC_TYPE : >+ SourceTypeBinding otherGenericType = (SourceTypeBinding) otherType; >+ if (paramType.genericType() != otherGenericType) >+ return true; >+ if (!paramType.isStatic()) { // static member types do not compare their enclosing >+ ReferenceBinding enclosing = enclosingType(); >+ if (enclosing != null) { >+ ReferenceBinding otherEnclosing = otherGenericType.enclosingType(); >+ if (otherEnclosing == null) return true; >+ if ((otherEnclosing.tagBits & TagBits.HasDirectWildcard) == 0) { >+ if (enclosing != otherEnclosing) return true; >+ } else { >+ if (!enclosing.isEquivalentTo(otherGenericType.enclosingType())) return true; >+ } >+ } >+ } >+ length = paramType.arguments == null ? 0 : paramType.arguments.length; >+ otherArguments = otherGenericType.typeVariables(); >+ otherLength = otherArguments == null ? 0 : otherArguments.length; >+ if (otherLength != length) >+ return true; >+ for (int i = 0; i < length; i++) { >+ if (paramType.arguments[i].isProvablyDistinctTypeArgument(otherArguments[i], paramType, i)) >+ return true; >+ } >+ return false; >+ >+ case Binding.RAW_TYPE : >+ return erasure() != otherType.erasure(); >+ } >+ return true; >+ >+ case Binding.RAW_TYPE : >+ >+ switch(otherType.kind()) { >+ >+ case Binding.GENERIC_TYPE : >+ case Binding.PARAMETERIZED_TYPE : >+ case Binding.RAW_TYPE : >+ return erasure() != otherType.erasure(); >+ } >+ return true; >+ >+ default : >+ break; >+ } >+ return true; >+} >+ >+/** >+ * Returns false if two given types could not intersect as argument types: >+ * List<Throwable> & List<Runnable> --> false >+ * List<? extends Throwable> & List<? extends Runnable> --> true >+ * List<? extends String> & List<? extends Runnable> --> false >+ */ >+private boolean isProvablyDistinctTypeArgument(TypeBinding otherArgument, final ParameterizedTypeBinding paramType, final int rank) { >+ if (this == otherArgument) >+ return false; >+ >+ TypeBinding upperBound1 = null; >+ TypeBinding lowerBound1 = null; >+ switch (kind()) { >+ case Binding.WILDCARD_TYPE : >+ WildcardBinding wildcard = (WildcardBinding) this; >+ switch (wildcard.boundKind) { >+ case Wildcard.EXTENDS: >+ upperBound1 = wildcard.bound; >+ break; >+ case Wildcard.SUPER: >+ lowerBound1 = wildcard.bound; >+ break; >+ case Wildcard.UNBOUND: >+ return false; >+ } >+ break; >+ case Binding.INTERSECTION_TYPE : >+ break; >+ case Binding.TYPE_PARAMETER : >+ final TypeVariableBinding variable = (TypeVariableBinding) this; >+ if (variable.firstBound == null) // unbound variable >+ return false; >+ if (variable.isCapture()) { >+ upperBound1 = variable.upperBound(); >+ break; >+ } >+ TypeBinding eliminatedType = (paramType.environment.convertEliminatingTypeVariables(variable, paramType.genericType(), rank, null)); >+ switch (eliminatedType.kind()) { >+ case Binding.WILDCARD_TYPE : >+ case Binding.INTERSECTION_TYPE : >+ wildcard = (WildcardBinding) eliminatedType; >+ switch (wildcard.boundKind) { >+ case Wildcard.EXTENDS: >+ upperBound1 = wildcard.bound; >+ break; >+ case Wildcard.SUPER: >+ lowerBound1 = wildcard.bound; >+ break; >+ case Wildcard.UNBOUND: >+ return false; >+ } >+ break; >+ } >+ break; >+ } >+ TypeBinding upperBound2 = null; >+ TypeBinding lowerBound2 = null; >+ switch (otherArgument.kind()) { >+ case Binding.WILDCARD_TYPE : >+ WildcardBinding otherWildcard = (WildcardBinding) otherArgument; >+ switch (otherWildcard.boundKind) { >+ case Wildcard.EXTENDS: >+ upperBound2 = otherWildcard.bound; >+ break; >+ case Wildcard.SUPER: >+ lowerBound2 = otherWildcard.bound; >+ break; >+ case Wildcard.UNBOUND: >+ return false; >+ } >+ break; >+ case Binding.INTERSECTION_TYPE : >+ 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 >+ break; >+ } >+ TypeBinding otherEliminatedType = (paramType.environment.convertEliminatingTypeVariables(otherVariable, paramType.genericType(), rank, null)); >+ switch (otherEliminatedType.kind()) { >+ case Binding.WILDCARD_TYPE : >+ case Binding.INTERSECTION_TYPE : >+ otherWildcard = (WildcardBinding) otherEliminatedType; >+ switch (otherWildcard.boundKind) { >+ case Wildcard.EXTENDS: >+ upperBound2 = otherWildcard.bound; >+ break; >+ case Wildcard.SUPER: >+ lowerBound2 = otherWildcard.bound; >+ break; >+ case Wildcard.UNBOUND: >+ return false; >+ } >+ break; >+ } break; >+ } >+ if (lowerBound1 != null) { >+ if (lowerBound2 != null) { >+ return false; // Object could always be a candidate >+ >+ } 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); >+ } else { >+ return otherArgument.isProvableDistinctSubType(upperBound1); >+ } >+ } else { >+ if (lowerBound2 != null) { >+ return !lowerBound2.isCompatibleWith(this); >+// return lowerBound2.isProvableDistinctSubType(this); >+ } else if (upperBound2 != null) { >+ return this.isProvableDistinctSubType(upperBound2); >+ } else { >+ return true; // ground types should have been the same >+ } >+ } >+} >+ >+public boolean isRawType() { >+ return false; >+} >+/** > * JLS(3) 4.7. > * Note: Foo<?>.Bar is also reifiable > */ >@@ -682,146 +922,6 @@ > } > > /** >- * Returns false if two given types could not intersect as argument types: >- * List<Throwable> & List<Runnable> --> false >- * List<? extends Throwable> & List<? extends Runnable> --> true >- * List<? extends String> & List<? extends Runnable> --> false >- */ >-public boolean isTypeArgumentIntersecting(TypeBinding otherArgument) { >- if (this == otherArgument) >- return true; >- switch (kind()) { >- >- // TYPE_PARAM & ANY TYPE >- case Binding.TYPE_PARAMETER: >- return true; >- >- case Binding.WILDCARD_TYPE: >- case Binding.INTERSECTION_TYPE: >- switch (otherArgument.kind()) { >- >- // WILDCARD & TYPE_PARAM >- case Binding.TYPE_PARAMETER: >- return true; >- >- // WILDCARD & WILDCARD >- case Binding.WILDCARD_TYPE: >- case Binding.INTERSECTION_TYPE: >- TypeBinding lowerBound1 = null; >- TypeBinding upperBound1 = null; >- WildcardBinding wildcard = (WildcardBinding) this; >- switch (wildcard.boundKind) { >- case Wildcard.EXTENDS: >- upperBound1 = wildcard.bound; >- break; >- case Wildcard.SUPER: >- lowerBound1 = wildcard.bound; >- break; >- case Wildcard.UNBOUND: >- } >- >- TypeBinding lowerBound2 = null; >- TypeBinding upperBound2 = null; >- WildcardBinding otherWildcard = (WildcardBinding) otherArgument; >- switch (otherWildcard.boundKind) { >- case Wildcard.EXTENDS: >- upperBound2 = otherWildcard.bound; >- break; >- case Wildcard.SUPER: >- lowerBound2 = otherWildcard.bound; >- break; >- case Wildcard.UNBOUND: >- } >- if (lowerBound1 != null) { >- if (lowerBound2 != null) { >- return true; // Object could always be a candidate >- >- } else if (upperBound2 != null) { >- return lowerBound1.isCompatibleWith(upperBound2); >- } else { >- return true; >- } >- } else if (upperBound1 != null) { >- if (upperBound1.isTypeVariable()) >- return true; >- if (lowerBound2 != null) { >- return lowerBound2.isCompatibleWith(upperBound1); >- >- } else if (upperBound2 != null) { >- if (upperBound1.isInterface()) { >- if (upperBound2.isInterface()) >- return true; >- if (upperBound2.isArrayType() >- || ((upperBound2 instanceof ReferenceBinding) && ((ReferenceBinding) upperBound2) >- .isFinal())) { >- return upperBound2 >- .isCompatibleWith(upperBound1); >- } >- return true; >- } else { >- if (upperBound2.isInterface()) { >- if (upperBound1.isArrayType() >- || ((upperBound1 instanceof ReferenceBinding) && ((ReferenceBinding) upperBound1) >- .isFinal())) { >- return upperBound1 >- .isCompatibleWith(upperBound2); >- } >- } else { >- return upperBound1 >- .isCompatibleWith(upperBound2); >- } >- } >- return true; >- } else { >- return true; >- } >- } else { >- return true; >- } >- >- // WILDCARD & OTHER TYPE >- default: >- wildcard = (WildcardBinding) this; >- switch (wildcard.boundKind) { >- case Wildcard.EXTENDS: >- return otherArgument.isCompatibleWith(wildcard.bound); >- case Wildcard.SUPER: >- return wildcard.bound.isCompatibleWith(otherArgument); >- case Wildcard.UNBOUND: >- default: >- return true; >- } >- } >- >- default: >- switch (otherArgument.kind()) { >- >- // OTHER TYPE & TYPE_PARAM >- case Binding.TYPE_PARAMETER: >- return true; >- >- // OTHER TYPE & WILDCARD >- case Binding.WILDCARD_TYPE: >- case Binding.INTERSECTION_TYPE: >- WildcardBinding otherWildcard = (WildcardBinding) otherArgument; >- switch (otherWildcard.boundKind) { >- case Wildcard.EXTENDS: >- return this.isCompatibleWith(otherWildcard.bound); >- case Wildcard.SUPER: >- return otherWildcard.bound.isCompatibleWith(this); >- case Wildcard.UNBOUND: >- default: >- return true; >- } >- >- // OTHER TYPE & OTHER TYPE >- default: >- return false; >- } >- } >-} >- >-/** > * Returns true if the type was declared as a type variable > */ > public boolean isTypeVariable() { >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java,v >retrieving revision 1.114 >diff -u -r1.114 ReferenceBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 24 Sep 2007 22:49:54 -0000 1.114 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 9 Oct 2007 14:48:53 -0000 >@@ -682,7 +682,7 @@ > TypeBinding match; > do { > match = otherType.findSuperTypeOriginatingFrom(currentType); >- if (match != null && !match.isIntersectingWith(currentType)) >+ if (match != null && match.isProvablyDistinct(currentType)) > return true; > > ReferenceBinding[] itsInterfaces = currentType.superInterfaces(); >@@ -708,7 +708,7 @@ > currentType = interfacesToVisit[i]; > if (currentType == otherType) return false; > match = otherType.findSuperTypeOriginatingFrom(currentType); >- if (match != null && !match.isIntersectingWith(currentType)) >+ if (match != null && match.isProvablyDistinct(currentType)) > return true; > > ReferenceBinding[] itsInterfaces = currentType.superInterfaces(); >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java,v >retrieving revision 1.63 >diff -u -r1.63 TypeVariableBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java 24 Sep 2007 22:49:54 -0000 1.63 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java 9 Oct 2007 14:48:55 -0000 >@@ -77,13 +77,13 @@ > } else { > TypeBinding match = wildcardBound.findSuperTypeOriginatingFrom(superclassBound); > if (match != null) { >- if (!match.isIntersectingWith(superclassBound)) { >+ if (superclassBound.isProvablyDistinct(match)) { > return TypeConstants.MISMATCH; > } > } else { > match = superclassBound.findSuperTypeOriginatingFrom(wildcardBound); > if (match != null) { >- if (!match.isIntersectingWith(wildcardBound)) { >+ if (match.isProvablyDistinct(wildcardBound)) { > return TypeConstants.MISMATCH; > } > } else { >@@ -106,7 +106,7 @@ > } else { > TypeBinding match = wildcardBound.findSuperTypeOriginatingFrom(superInterfaceBound); > if (match != null) { >- if (!match.isIntersectingWith(superInterfaceBound)) { >+ if (superInterfaceBound.isProvablyDistinct(match)) { > return TypeConstants.MISMATCH; > } > } else if (mustImplement) { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java,v >retrieving revision 1.113 >diff -u -r1.113 Expression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java 24 Sep 2007 22:49:54 -0000 1.113 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java 9 Oct 2007 14:48:51 -0000 >@@ -27,7 +27,6 @@ > import org.eclipse.jdt.internal.compiler.lookup.ClassScope; > import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; > import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; >-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding; > import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; > import org.eclipse.jdt.internal.compiler.lookup.Scope; > import org.eclipse.jdt.internal.compiler.lookup.TagBits; >@@ -520,63 +519,6 @@ > } > } > >-/** >- * Returns true if the two types are statically known to be different at compile-time, >- * e.g. a type variable is not provably known to be distinct from another type >- */ >-public final boolean checkProvablyDistinctTypes(Scope scope, TypeBinding castType, TypeBinding expressionType, int depth) { >- if (castType == expressionType) >- return false; >- if (depth > 1) >- return true; >- switch (expressionType.kind()) { >- case Binding.TYPE_PARAMETER: >- case Binding.WILDCARD_TYPE: >- case Binding.INTERSECTION_TYPE: >- return false; >- } >- switch (castType.kind()) { >- case Binding.TYPE_PARAMETER: >- case Binding.WILDCARD_TYPE: >- case Binding.INTERSECTION_TYPE: >- return false; >- >- case Binding.PARAMETERIZED_TYPE: >- ParameterizedTypeBinding parameterizedType = (ParameterizedTypeBinding) castType; >- if (checkProvablyDistinctTypes(scope, parameterizedType.genericType(), expressionType.erasure(), depth)) >- return true; >- switch (expressionType.kind()) { >- case Binding.GENERIC_TYPE: >- case Binding.RAW_TYPE: >- return false; >- case Binding.PARAMETERIZED_TYPE: >- TypeBinding[] arguments = parameterizedType.arguments; >- if (arguments == null) >- return false; >- ParameterizedTypeBinding otherParameterizedType = (ParameterizedTypeBinding) expressionType; >- TypeBinding[] otherArguments = otherParameterizedType.arguments; >- if (otherArguments == null) >- return false; >- for (int i = 0, length = arguments.length; i < length; i++) { >- if (checkProvablyDistinctTypes(scope, arguments[i], otherArguments[i], depth + 1)) >- return true; >- } >- return false; >- >- } >- break; >- >- case Binding.RAW_TYPE: >- if (depth > 0) return true; >- return checkProvablyDistinctTypes(scope, castType.erasure(), expressionType.erasure(), 0); >- >- case Binding.GENERIC_TYPE: >- if (depth > 0) return true; >- return castType != expressionType.erasure(); >- } >- return castType != expressionType; >-} >- > public boolean checkUnsafeCast(Scope scope, TypeBinding castType, TypeBinding expressionType, TypeBinding match, boolean isNarrowing) { > if (match == castType) { > if (!isNarrowing) tagAsUnnecessaryCast(scope, castType); >@@ -587,8 +529,8 @@ > || expressionType.isBoundParameterizedType())) { > > if(isNarrowing >- ? checkProvablyDistinctTypes(scope, match, expressionType, 0) >- : checkProvablyDistinctTypes(scope, castType, match, 0)) { >+ ? match.isProvablyDistinct(expressionType) >+ : castType.isProvablyDistinct(match)) { > return false; > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java,v >retrieving revision 1.112 >diff -u -r1.112 CastExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java 24 Sep 2007 22:49:54 -0000 1.112 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java 9 Oct 2007 14:48:51 -0000 >@@ -280,8 +280,8 @@ > } > if (match != null) { > if (isNarrowing >- ? checkProvablyDistinctTypes(scope, match, expressionType, 0) >- : checkProvablyDistinctTypes(scope, castType, match, 0)) { >+ ? match.isProvablyDistinct(expressionType) >+ : castType.isProvablyDistinct(match)) { > return false; > } > }
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 158870
: 79958