6557954: Inner class type parameters doesn't get substituted when checking type well-formedness

Validator.visitTypeApply should substitute all formal typevars with actual parameters

Reviewed-by: jjg
This commit is contained in:
Maurizio Cimadamore 2008-10-23 18:29:11 +01:00
parent 0408a1adae
commit 5a17e28602
2 changed files with 40 additions and 4 deletions

View File

@ -802,10 +802,10 @@ public class Check {
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 @@ public class Check {
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);

View File

@ -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;
}