6557954: Inner class type parameters doesn't get substituted when checking type well-formedness
Summary: Validator.visitTypeApply should substitute all formal typevars with actual parameters
Reviewed-by: jjg
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Oct 23 18:10:23 2008 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Oct 23 18:29:11 2008 +0100
@@ -802,10 +802,10 @@
public void visitTypeApply(JCTypeApply tree) {
if (tree.type.tag == CLASS) {
- List<Type> formals = tree.type.tsym.type.getTypeArguments();
- List<Type> actuals = tree.type.getTypeArguments();
+ List<Type> formals = tree.type.tsym.type.allparams();
+ List<Type> actuals = tree.type.allparams();
List<JCExpression> args = tree.arguments;
- List<Type> forms = formals;
+ List<Type> forms = tree.type.tsym.type.getTypeArguments();
ListBuffer<TypeVar> tvars_buf = new ListBuffer<TypeVar>();
// For matching pairs of actual argument types `a' and
@@ -828,7 +828,7 @@
args = tree.arguments;
List<Type> tvars_cap = types.substBounds(formals,
formals,
- types.capture(tree.type).getTypeArguments());
+ types.capture(tree.type).allparams());
while (args.nonEmpty() && tvars_cap.nonEmpty()) {
// Let the actual arguments know their bound
args.head.type.withTypeVar((TypeVar)tvars_cap.head);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/T6557954.java Thu Oct 23 18:29:11 2008 +0100
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6557954
+ * @summary Inner class type parameters doesn't get substituted when checking type well-formedness
+ * @author Maurizio Cimadamore
+ *
+ * @compile T6557954.java
+ */
+
+class T6557954<T> {
+ class Foo<U extends T> {}
+ T6557954<Number>.Foo<Integer> f;
+}
\ No newline at end of file