### 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.686 diff -u -r1.686 GenericTypeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 29 Jan 2008 10:15:16 -0000 1.686 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 31 Jan 2008 15:00:52 -0000 @@ -42124,4 +42124,505 @@ }, ""); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 +public void test1269() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " // some functor and functor instances definitions\n" + + " static interface OO { \n" + + " public T eval(E x);\n" + + " }\n" + + " static interface TO extends OO {\n" + + " public String eval(T x);\n" + + " }\n" + + " static interface TT extends TO {\n" + + " public String eval(String x);\n" + + " }\n" + + " static final TO FUNC1 = null;\n" + + " static final TT FUNC2 = null;\n" + + "\n" + + " // some functor combinators\n" + + " static TO combine(final TT x, final TO y) { // # 1\n" + + " System.out.println(\"#1#\");\n" + + " return new TO() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " // body of the test\n" + + " static void put(Class type, TO func) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " put(Integer.class, combine(FUNC2, FUNC1));\n" + + " }\n" + + "}\n", // ================= + }, + "#1#"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1270() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " // some functor and functor instances definitions\n" + + " static interface OO { \n" + + " public T eval(E x);\n" + + " }\n" + + " static interface TO extends OO {\n" + + " public String eval(T x);\n" + + " }\n" + + " static interface TT extends TO {\n" + + " public String eval(String x);\n" + + " }\n" + + " static final TO FUNC1 = null;\n" + + " static final TT FUNC2 = null;\n" + + "\n" + + " // some functor combinators\n" + + " static TO combine(final TO x, final OO y) { // # 2\n" + + " System.out.println(\"#2#\");\n" + + " return new TO() { public String eval(T o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " // body of the test\n" + + " static void put(Class type, TO func) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " put(Integer.class, combine(FUNC2, FUNC1));\n" + + " }\n" + + "}\n", // ================= + }, + "#2#"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1271() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " // some functor and functor instances definitions\n" + + " static interface OO { \n" + + " public T eval(E x);\n" + + " }\n" + + " static interface TO extends OO {\n" + + " public String eval(T x);\n" + + " }\n" + + " static interface TT extends TO {\n" + + " public String eval(String x);\n" + + " }\n" + + " static final TO FUNC1 = null;\n" + + " static final TT FUNC2 = null;\n" + + "\n" + + " // some functor combinators\n" + + " static OO combine(final OO x, final OO y) { // # 3\n" + + " System.out.println(\"#3#\");\n" + + " return new OO() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + + " }\n" + + " // body of the test\n" + + " static void put(Class type, TO func) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " put(Integer.class, combine(FUNC2, FUNC1));\n" + + " }\n" + + "}\n", // ================= + }, + "----------\n" + + "1. ERROR in X.java (at line 24)\n" + + " put(Integer.class, combine(FUNC2, FUNC1));\n" + + " ^^^\n" + + "The method put(Class, X.TO) in the type X is not applicable for the arguments (Class, X.OO)\n" + + "----------\n"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1272() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " // some functor and functor instances definitions\n" + + " static interface OO { \n" + + " public T eval(E x);\n" + + " }\n" + + " static interface TO extends OO {\n" + + " public String eval(T x);\n" + + " }\n" + + " static interface TT extends TO {\n" + + " public String eval(String x);\n" + + " }\n" + + " static final TO FUNC1 = null;\n" + + " static final TT FUNC2 = null;\n" + + "\n" + + " // some functor combinators\n" + + " static OO combine(final OO x, final OO y) { // # 3\n" + + " System.out.print(\"#3#\");\n" + + " return new OO() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + + " }\n" + + " // body of the test\n" + + " static void put(Class type, TO func) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " try {\n" + + " put(Integer.class, (TO)combine(FUNC2, FUNC1));\n" + + " } catch(ClassCastException e) {\n" + + " System.out.println(\"#CLASSCAST#\");\n" + + " }\n" + + " }\n" + + "}\n", // ================= + }, + "#3##CLASSCAST#"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1273() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " // some functor and functor instances definitions\n" + + " static interface OO { \n" + + " public T eval(E x);\n" + + " }\n" + + " static interface TO extends OO {\n" + + " public String eval(T x);\n" + + " }\n" + + " static interface TT extends TO {\n" + + " public String eval(String x);\n" + + " }\n" + + " static final TO FUNC1 = null;\n" + + " static final TT FUNC2 = null;\n" + + "\n" + + " // some functor combinators\n" + + " static TO combine(final TT x, final TO y) { // # 1\n" + + " System.out.println(\"#1#\");\n" + + " return new TO() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " static TO combine(final TO x, final OO y) { // # 2\n" + + " System.out.println(\"#2#\");\n" + + " return new TO() { public String eval(T o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " // body of the test\n" + + " static void put(Class type, TO func) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " put(Integer.class, combine(FUNC2, FUNC1));\n" + + " }\n" + + "}\n", // ================= + }, + "#1#"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1274() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " // some functor and functor instances definitions\n" + + " static interface OO { \n" + + " public T eval(E x);\n" + + " }\n" + + " static interface TO extends OO {\n" + + " public String eval(T x);\n" + + " }\n" + + " static interface TT extends TO {\n" + + " public String eval(String x);\n" + + " }\n" + + " static final TO FUNC1 = null;\n" + + " static final TT FUNC2 = null;\n" + + "\n" + + " // some functor combinators\n" + + " static TO combine(final TT x, final TO y) { // # 1\n" + + " System.out.println(\"#1#\");\n" + + " return new TO() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " static TO combine(final TO x, final OO y) { // # 2\n" + + " System.out.println(\"#2#\");\n" + + " return new TO() { public String eval(T o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " // body of the test\n" + + " static void put(Class type, TO func) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " put(Integer.class, X.combine(FUNC2, FUNC1));\n" + + " }\n" + + "}\n", // ================= + }, + "#1#"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1275() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " // some functor and functor instances definitions\n" + + " static interface OO { \n" + + " public T eval(E x);\n" + + " }\n" + + " static interface TO extends OO {\n" + + " public String eval(T x);\n" + + " }\n" + + " static interface TT extends TO {\n" + + " public String eval(String x);\n" + + " }\n" + + " static final TO FUNC1 = null;\n" + + " static final TT FUNC2 = null;\n" + + "\n" + + " // some functor combinators\n" + + " static TO combine(final TT x, final TO y) { // # 1\n" + + " System.out.println(\"#1#\");\n" + + " return new TO() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " static OO combine(final OO x, final OO y) { // # 3\n" + + " System.out.println(\"#3#\");\n" + + " return new OO() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + + " }\n" + + " // body of the test\n" + + " static void put(Class type, TO func) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " put(Integer.class, combine(FUNC2, FUNC1));\n" + + " }\n" + + "}\n", // ================= + }, + "#1#"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1276() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " // some functor and functor instances definitions\n" + + " static interface OO { \n" + + " public T eval(E x);\n" + + " }\n" + + " static interface TO extends OO {\n" + + " public String eval(T x);\n" + + " }\n" + + " static interface TT extends TO {\n" + + " public String eval(String x);\n" + + " }\n" + + " static final TO FUNC1 = null;\n" + + " static final TT FUNC2 = null;\n" + + "\n" + + " // some functor combinators\n" + + " static TO combine(final TT x, final TO y) { // # 1\n" + + " System.out.println(\"#1#\");\n" + + " return new TO() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " static OO combine(final OO x, final OO y) { // # 3\n" + + " System.out.println(\"#3#\");\n" + + " return new OO() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + + " }\n" + + " // body of the test\n" + + " static void put(Class type, TO func) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " put(Integer.class, X.combine(FUNC2, FUNC1));\n" + + " }\n" + + "}\n", // ================= + }, + "#1#"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1277() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " // some functor and functor instances definitions\n" + + " static interface OO { \n" + + " public T eval(E x);\n" + + " }\n" + + " static interface TO extends OO {\n" + + " public String eval(T x);\n" + + " }\n" + + " static interface TT extends TO {\n" + + " public String eval(String x);\n" + + " }\n" + + " static final TO FUNC1 = null;\n" + + " static final TT FUNC2 = null;\n" + + "\n" + + " // some functor combinators\n" + + " static TO combine(final TO x, final OO y) { // # 2\n" + + " System.out.println(\"#2#\");\n" + + " return new TO() { public String eval(T o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " static OO combine(final OO x, final OO y) { // # 3\n" + + " System.out.println(\"#3#\");\n" + + " return new OO() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + + " }\n" + + " // body of the test\n" + + " static void put(Class type, TO func) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " put(Integer.class, combine(FUNC2, FUNC1));\n" + + " }\n" + + "}\n", // ================= + }, + "#2#"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1278() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " // some functor and functor instances definitions\n" + + " static interface OO { \n" + + " public T eval(E x);\n" + + " }\n" + + " static interface TO extends OO {\n" + + " public String eval(T x);\n" + + " }\n" + + " static interface TT extends TO {\n" + + " public String eval(String x);\n" + + " }\n" + + " static final TO FUNC1 = null;\n" + + " static final TT FUNC2 = null;\n" + + "\n" + + " // some functor combinators\n" + + " static TO combine(final TT x, final TO y) { // # 1\n" + + " System.out.println(\"#1#\");\n" + + " return new TO() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " static TO combine(final TO x, final OO y) { // # 2\n" + + " System.out.println(\"#2#\");\n" + + " return new TO() { public String eval(T o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " static OO combine(final OO x, final OO y) { // # 3\n" + + " System.out.println(\"#3#\");\n" + + " return new OO() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + + " }\n" + + " // body of the test\n" + + " static void put(Class type, TO func) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " put(Integer.class, combine(FUNC2, FUNC1));\n" + + " }\n" + + "}\n", // ================= + }, + "#1#"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1279() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " // some functor and functor instances definitions\n" + + " static interface OO { \n" + + " public T eval(E x);\n" + + " }\n" + + " static interface TO extends OO {\n" + + " public String eval(T x);\n" + + " }\n" + + " static interface TT extends TO {\n" + + " public String eval(String x);\n" + + " }\n" + + " static final TO FUNC1 = null;\n" + + " static final TT FUNC2 = null;\n" + + "\n" + + " // some functor combinators\n" + + " static TO combine(final TT x, final TO y) { // # 1\n" + + " System.out.println(\"#1#\");\n" + + " return new TO() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " static TO combine(final TO x, final OO y) { // # 2\n" + + " System.out.println(\"#2#\");\n" + + " return new TO() { public String eval(T o) { return x.eval(y.eval(o)); } }; \n" + + " }\n" + + " static OO combine(final OO x, final OO y) { // # 3\n" + + " System.out.println(\"#3#\");\n" + + " return new OO() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + + " }\n" + + " // body of the test\n" + + " static void put(Class type, TO func) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " put(Integer.class, X.combine(FUNC2, FUNC1));\n" + + " }\n" + + "}\n", // ================= + }, + "#1#"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1280() { + this.runConformTest( + new String[] { + "X.java", + "interface OO {}\n" + + "interface TO extends OO {}\n" + + "interface TT extends TO {}\n" + + "\n" + + "public class X {\n" + + " TO combine(final TO x, final OO y) { return null; }\n" + + " void foo(TT tt, TO too) {\n" + + " combine(tt, too);\n" + + " }\n" + + "}", // ================= + }, + ""); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1281() { + this.runConformTest( + new String[] { + "X.java", + "interface OO {}\n" + + "interface TO extends OO {}\n" + + "interface TT extends TO {}\n" + + "\n" + + "public class X {\n" + + " TO combine(final TO x, final OO[] y) { return null; }\n" + + " void foo(TT tt, TO[] too) {\n" + + " combine(tt, too);\n" + + " }\n" + + "}", // ================= + }, + ""); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1282() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " static interface OO {}\n" + + " static interface TO extends OO {}\n" + + " static interface TT extends TO {}\n" + + " \n" + + " TO combine(TT x, TO y) { return null; }\n" + + " void foo(TO too, OO oo) {\n" + + " combine(too, oo);\n" + + " }\n" + + "}", // ================= + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\r\n" + + " combine(too, oo);\r\n" + + " ^^^^^^^\n" + + "The method combine(X.TT, X.TO) in the type X is not applicable for the arguments (X.TO, X.OO)\n" + + "----------\n"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation +public void test1283() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " static interface OO {}\n" + + " static interface TO extends OO {}\n" + + " static interface TT extends TO {}\n" + + " \n" + + " TO combine(TT[] x, TO[] y) { return null; }\n" + + " void foo(TO[] too, OO[] oo) {\n" + + " combine(too, oo);\n" + + " }\n" + + "}", // ================= + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\r\n" + + " combine(too, oo);\r\n" + + " ^^^^^^^\n" + + "The method combine(X.TT[], X.TO[]) in the type X is not applicable for the arguments (X.TO[], X.OO[])\n" + + "----------\n"); +} } #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java,v retrieving revision 1.61 diff -u -r1.61 ParameterizedGenericMethodBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java 7 Jan 2008 14:16:20 -0000 1.61 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java 31 Jan 2008 15:00:55 -0000 @@ -470,7 +470,7 @@ TypeBinding[] newArguments = new TypeBinding[length]; for (int i = 0; i < length; i++) { TypeVariableBinding originalVariable = originalVariables[i]; - if (originalVariable.boundsCount() == 1) { + if (originalVariable.boundsCount() <= 1) { newArguments[i] = this.environment.convertToRawType(originalVariable.upperBound(), false /*do not force conversion of enclosing types*/); } else { newArguments[i] = this.environment.convertToRawType( 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.92 diff -u -r1.92 TypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 12 Oct 2007 09:37:00 -0000 1.92 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 31 Jan 2008 15:00:55 -0000 @@ -804,138 +804,149 @@ if (this == otherType) return true; switch (otherType.kind()) { - // allow wildcard containment - case Binding.WILDCARD_TYPE: - case Binding.INTERSECTION_TYPE: - - TypeBinding lowerBound = this; - TypeBinding upperBound = this; - switch (this.kind()) { - case Binding.WILDCARD_TYPE: - case Binding.INTERSECTION_TYPE: - WildcardBinding wildcard = (WildcardBinding) this; - switch (wildcard.boundKind) { - case Wildcard.EXTENDS: - if (wildcard.otherBounds != null) // intersection type - break; - upperBound = wildcard.bound; - lowerBound = null; + // allow wildcard containment + case Binding.WILDCARD_TYPE: + case Binding.INTERSECTION_TYPE: + + TypeBinding lowerBound = this; + TypeBinding upperBound = this; + switch (this.kind()) { + case Binding.WILDCARD_TYPE: + case Binding.INTERSECTION_TYPE: + WildcardBinding wildcard = (WildcardBinding) this; + switch (wildcard.boundKind) { + case Wildcard.EXTENDS: + if (wildcard.otherBounds != null) // intersection type + break; + upperBound = wildcard.bound; + lowerBound = null; + break; + case Wildcard.SUPER: + upperBound = wildcard; + lowerBound = wildcard.bound; + break; + case Wildcard.UNBOUND: + upperBound = wildcard; + lowerBound = null; + } break; + case Binding.TYPE_PARAMETER: + if (this.isCapture()) { + CaptureBinding capture = (CaptureBinding) this; + if (capture.lowerBound != null) + lowerBound = capture.lowerBound; + } + } + WildcardBinding otherWildcard = (WildcardBinding) otherType; + if (otherWildcard.otherBounds != null) + return false; // not a true wildcard (intersection type) + TypeBinding otherBound = otherWildcard.bound; + switch (otherWildcard.boundKind) { + case Wildcard.EXTENDS: + if (otherBound == this) + return true; // ? extends T <= ? extends ? extends T + if (upperBound == null) + return false; + TypeBinding match = upperBound.findSuperTypeOriginatingFrom(otherBound); + if (match != null && (match = match.leafComponentType()).isRawType()) { + return match == otherBound.leafComponentType(); // forbide: Collection <= ? extends Collection + // forbide: Collection[] <= ? extends Collection[] + } + return upperBound.isCompatibleWith(otherBound); + case Wildcard.SUPER: - upperBound = wildcard; - lowerBound = wildcard.bound; - break; + if (otherBound == this) + return true; // ? super T <= ? super ? super T + if (lowerBound == null) + return false; + match = otherBound.findSuperTypeOriginatingFrom(lowerBound); + if (match != null && (match = match.leafComponentType()).isRawType()) { + return match == lowerBound.leafComponentType(); // forbide: Collection <= ? super Collection + // forbide: Collection[] <= ? super Collection[] + } + return otherBound.isCompatibleWith(lowerBound); + case Wildcard.UNBOUND: - upperBound = wildcard; - lowerBound = null; - } - break; - case Binding.TYPE_PARAMETER: - if (this.isCapture()) { - CaptureBinding capture = (CaptureBinding) this; - if (capture.lowerBound != null) - lowerBound = capture.lowerBound; - } - } - WildcardBinding otherWildcard = (WildcardBinding) otherType; - if (otherWildcard.otherBounds != null) - return false; // not a true wildcard (intersection type) - TypeBinding otherBound = otherWildcard.bound; - switch (otherWildcard.boundKind) { - case Wildcard.EXTENDS: - if (otherBound == this) - return true; // ? extends T <= ? extends ? extends T - if (upperBound == null) - return false; - TypeBinding match = upperBound.findSuperTypeOriginatingFrom(otherBound); - if (match != null && (match = match.leafComponentType()).isRawType()) { - return match == otherBound.leafComponentType(); // forbide: Collection <= ? extends Collection - // forbide: Collection[] <= ? extends Collection[] + default: + return true; } - return upperBound.isCompatibleWith(otherBound); - - case Wildcard.SUPER: - if (otherBound == this) - return true; // ? super T <= ? super ? super T - if (lowerBound == null) + // allow List to match List (and reciprocally) + case Binding.PARAMETERIZED_TYPE: + if (!this.isParameterizedType()) return false; - match = otherBound.findSuperTypeOriginatingFrom(lowerBound); - if (match != null && (match = match.leafComponentType()).isRawType()) { - return match == lowerBound.leafComponentType(); // forbide: Collection <= ? super Collection - // forbide: Collection[] <= ? super Collection[] - } - return otherBound.isCompatibleWith(lowerBound); - - case Wildcard.UNBOUND: - default: - return true; - } - // allow List to match List (and reciprocally) - case Binding.PARAMETERIZED_TYPE: - if (!this.isParameterizedType()) - return false; - ParameterizedTypeBinding paramType = (ParameterizedTypeBinding) this; - ParameterizedTypeBinding otherParamType = (ParameterizedTypeBinding) otherType; - if (paramType.actualType() != otherParamType.actualType()) - return false; - 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 false; - if ((otherEnclosing.tagBits & TagBits.HasDirectWildcard) == 0) { - if (enclosing != otherEnclosing) - return false; - } else { - if (!enclosing.isEquivalentTo(otherParamType.enclosingType())) + ParameterizedTypeBinding paramType = (ParameterizedTypeBinding) this; + ParameterizedTypeBinding otherParamType = (ParameterizedTypeBinding) otherType; + if (paramType.actualType() != otherParamType.actualType()) + return false; + 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 false; + if ((otherEnclosing.tagBits & TagBits.HasDirectWildcard) == 0) { + if (enclosing != otherEnclosing) + return false; + } else { + if (!enclosing.isEquivalentTo(otherParamType.enclosingType())) + return false; + } } } - } - int length = paramType.arguments == null ? 0 : paramType.arguments.length; - TypeBinding[] otherArguments = otherParamType.arguments; - int otherLength = otherArguments == null ? 0 : otherArguments.length; - if (otherLength != length) - return false; - nextArgument: for (int i = 0; i < length; i++) { - TypeBinding argument = paramType.arguments[i]; - TypeBinding otherArgument = otherArguments[i]; - if (argument == otherArgument) - continue nextArgument; - int kind = argument.kind(); - if (otherArgument.kind() != kind) + int length = paramType.arguments == null ? 0 : paramType.arguments.length; + TypeBinding[] otherArguments = otherParamType.arguments; + int otherLength = otherArguments == null ? 0 : otherArguments.length; + if (otherLength != length) return false; - switch (kind) { - case Binding.PARAMETERIZED_TYPE: - if (argument.isTypeArgumentContainedBy(otherArgument)) // recurse + nextArgument: for (int i = 0; i < length; i++) { + TypeBinding argument = paramType.arguments[i]; + TypeBinding otherArgument = otherArguments[i]; + if (argument == otherArgument) continue nextArgument; - break; + int kind = argument.kind(); + if (otherArgument.kind() != kind) + return false; + switch (kind) { + case Binding.PARAMETERIZED_TYPE: + if (argument.isTypeArgumentContainedBy(otherArgument)) // recurse + continue nextArgument; + break; + case Binding.WILDCARD_TYPE: + case Binding.INTERSECTION_TYPE: + WildcardBinding wildcard = (WildcardBinding) argument; + otherWildcard = (WildcardBinding) otherArgument; + switch (wildcard.boundKind) { + case Wildcard.EXTENDS: + // match "? extends " with "?" + if (otherWildcard.boundKind == Wildcard.UNBOUND + && wildcard.bound == wildcard.typeVariable().upperBound()) + continue nextArgument; + break; + case Wildcard.SUPER: + break; + case Wildcard.UNBOUND: + // match "?" with "? extends " + if (otherWildcard.boundKind == Wildcard.EXTENDS + && otherWildcard.bound == otherWildcard.typeVariable().upperBound()) + continue nextArgument; + break; + } + break; + } + return false; + } + return true; + } + // (? super Object) <= Object + if (otherType.id == TypeIds.T_JavaLangObject) { + switch (this.kind()) { case Binding.WILDCARD_TYPE: - case Binding.INTERSECTION_TYPE: - WildcardBinding wildcard = (WildcardBinding) argument; - otherWildcard = (WildcardBinding) otherArgument; - switch (wildcard.boundKind) { - case Wildcard.EXTENDS: - // match "? extends " with "?" - if (otherWildcard.boundKind == Wildcard.UNBOUND - && wildcard.bound == wildcard.typeVariable().upperBound()) - continue nextArgument; - break; - case Wildcard.SUPER: - break; - case Wildcard.UNBOUND: - // match "?" with "? extends " - if (otherWildcard.boundKind == Wildcard.EXTENDS - && otherWildcard.bound == otherWildcard.typeVariable().upperBound()) - continue nextArgument; - break; + WildcardBinding wildcard = (WildcardBinding) this; + if (wildcard.boundKind == Wildcard.SUPER && wildcard.bound.id == TypeIds.T_JavaLangObject) { + return true; } break; - } - return false; } - return true; } return false; }