### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core 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.74 diff -u -r1.74 TypeVariableBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java 14 May 2009 14:50:31 -0000 1.74 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java 25 Oct 2010 08:49:17 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Stephan Herrmann - Contribution for bug 282152 - [1.5][compiler] Generics code rejected by Eclipse but accepted by javac *******************************************************************************/ package org.eclipse.jdt.internal.compiler.lookup; @@ -114,6 +115,9 @@ break; case Wildcard.SUPER : + // if the wildcard is lower-bounded by a type variable that has no relevant upper bound there's nothing to check here (bug 282152): + if (wildcard.bound.isTypeVariable() && ((TypeVariableBinding)wildcard.bound).superclass.id == TypeIds.T_JavaLangObject) + break; return boundCheck(substitution, wildcard.bound); case Wildcard.UNBOUND : #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java,v retrieving revision 1.1 diff -u -r1.1 GenericsRegressionTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java 6 Sep 2010 03:26:04 -0000 1.1 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java 25 Oct 2010 08:49:22 -0000 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Stephan Herrmann - Contribution for bug 282152 - [1.5][compiler] Generics code rejected by Eclipse but accepted by javac *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; @@ -379,4 +380,138 @@ "Incompatible operand types Class and Class\n" + "----------\n"); } + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282152 +public void test282152() { + this.runConformTest( + new String[] { + "Test.java", + "public interface Test {\n" + + " public void test(Test t, U value);\n" + + " public void setValue(T v);" + + "}", + "Impl.java", + "public class Impl implements Test{\n" + + " T val;" + + " public void test(Test t, U value) {\n" + + " t.setValue(value);\n" + + " }\n" + + " public void setValue(T v) {\n" + + " this.val = v;\n" + + " }\n" + + "}", + "Client.java", + "public class Client {\n" + + " void test() {\n" + + " Impl t1 = new Impl();\n" + + " Double n = Double.valueOf(3.14);\n" + + " t1.test(new Impl(), n);\n" + + " }\n" + + "}\n" + }, + ""); // no specific success output string +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282152 +// violating lower bound +public void test282152b() { + this.runNegativeTest( + new String[] { + "Test.java", + "public interface Test {\n" + + " public void test(Test t, U value);\n" + + " public void setValue(T v);" + + "}", + "Impl.java", + "public class Impl implements Test{\n" + + " T val;" + + " public void test(Test t, U value) {\n" + + " t.setValue(value);\n" + + " }\n" + + " public void setValue(T v) {\n" + + " this.val = v;\n" + + " }\n" + + "}", + "Client.java", + "public class Client {\n" + + " void test() {\n" + + " Impl t1 = new Impl();\n" + + " Number n = Double.valueOf(3.14);\n" + + " t1.test(new Impl(), n);\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in Client.java (at line 5)\n" + + " t1.test(new Impl(), n);\n" + + " ^^^^\n" + + "The method test(Test, U) in the type Impl is not applicable for the arguments (Impl, Number)\n" + + "----------\n"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282152 +// contradictory bounds +public void test282152c() { + this.runNegativeTest( + new String[] { + "Test.java", + "public interface Test {\n" + + " public void test(Test t, U value);\n" + + " public void setValue(T v);" + + "}" + }, + "----------\n" + + "1. ERROR in Test.java (at line 2)\n" + + " public void test(Test t, U value);\n" + + " ^^^^^^^^^\n" + + "Bound mismatch: The type ? super U is not a valid substitute for the bounded parameter of the type Test\n" + + "----------\n"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282152 +// compatible constraints +public void test282152d() { + this.runConformTest( + new String[] { + "Test.java", + "public interface Test {\n" + + " public void test(Test t, U value);\n" + + " public void setValue(T v);" + + "}", + "Impl.java", + "public class Impl implements Test{\n" + + " T val;" + + " public void test(Test t, U value) {\n" + + " t.setValue(value);\n" + + " }\n" + + " public void setValue(T v) {\n" + + " this.val = v;\n" + + " }\n" + + "}", + "Client.java", + "public class Client {\n" + + " void test() {\n" + + " Impl t1 = new Impl();\n" + + " Integer i = Integer.valueOf(3);\n" + + " t1.test(new Impl(), i);\n" + + " }\n" + + "}\n" + }, + ""); // no specific success output string +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282152 +// direct use of type variable does not involve capture, thus no merging of constraints happens +public void test282152e() { + this.runNegativeTest( + new String[] { + "Test.java", + "public interface Test {\n" + + " public void test(Test t, U value);\n" + + " public void setValue(T v);" + + "}" + }, + "----------\n" + + "1. ERROR in Test.java (at line 2)\n" + + " public void test(Test t, U value);\n" + + " ^\n" + + "Bound mismatch: The type U is not a valid substitute for the bounded parameter of the type Test\n" + + "----------\n"); +} } \ No newline at end of file