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

Thu, 23 Oct 2008 18:29:11 +0100

author
mcimadamore
date
Thu, 23 Oct 2008 18:29:11 +0100
changeset 158
c6e3fc6dda61
parent 157
433ee48257c0
child 159
5e54a59bcee7

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

src/share/classes/com/sun/tools/javac/comp/Check.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/T6557954.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Oct 23 18:10:23 2008 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Oct 23 18:29:11 2008 +0100
     1.3 @@ -802,10 +802,10 @@
     1.4  
     1.5          public void visitTypeApply(JCTypeApply tree) {
     1.6              if (tree.type.tag == CLASS) {
     1.7 -                List<Type> formals = tree.type.tsym.type.getTypeArguments();
     1.8 -                List<Type> actuals = tree.type.getTypeArguments();
     1.9 +                List<Type> formals = tree.type.tsym.type.allparams();
    1.10 +                List<Type> actuals = tree.type.allparams();
    1.11                  List<JCExpression> args = tree.arguments;
    1.12 -                List<Type> forms = formals;
    1.13 +                List<Type> forms = tree.type.tsym.type.getTypeArguments();
    1.14                  ListBuffer<TypeVar> tvars_buf = new ListBuffer<TypeVar>();
    1.15  
    1.16                  // For matching pairs of actual argument types `a' and
    1.17 @@ -828,7 +828,7 @@
    1.18                  args = tree.arguments;
    1.19                  List<Type> tvars_cap = types.substBounds(formals,
    1.20                                            formals,
    1.21 -                                          types.capture(tree.type).getTypeArguments());
    1.22 +                                          types.capture(tree.type).allparams());
    1.23                  while (args.nonEmpty() && tvars_cap.nonEmpty()) {
    1.24                      // Let the actual arguments know their bound
    1.25                      args.head.type.withTypeVar((TypeVar)tvars_cap.head);
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/generics/T6557954.java	Thu Oct 23 18:29:11 2008 +0100
     2.3 @@ -0,0 +1,36 @@
     2.4 +/*
     2.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    2.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    2.24 + * have any questions.
    2.25 + */
    2.26 +
    2.27 +/*
    2.28 + * @test
    2.29 + * @bug     6557954
    2.30 + * @summary Inner class type parameters doesn't get substituted when checking type well-formedness
    2.31 + * @author Maurizio Cimadamore
    2.32 + *
    2.33 + * @compile T6557954.java
    2.34 + */
    2.35 +
    2.36 +class T6557954<T> {
    2.37 +    class Foo<U extends T> {}
    2.38 +    T6557954<Number>.Foo<Integer> f;
    2.39 +}
    2.40 \ No newline at end of file

mercurial