6718364: inference fails when a generic method is invoked with raw arguments

Fri, 08 Aug 2008 17:38:20 +0100

author
mcimadamore
date
Fri, 08 Aug 2008 17:38:20 +0100
changeset 93
30a415f8667f
parent 92
d635feaf3747
child 94
6542933af8f4

6718364: inference fails when a generic method is invoked with raw arguments
Summary: Bug in the implementation of Types.isSubtypeUnchecked
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/code/Types.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/inference/6718364/T6718364.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/inference/6718364/T6718364.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Aug 08 15:16:25 2008 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Aug 08 17:38:20 2008 +0100
     1.3 @@ -305,6 +305,11 @@
     1.4          else if (t.tag == TYPEVAR) {
     1.5              return isSubtypeUnchecked(t.getUpperBound(), s, warn);
     1.6          }
     1.7 +        else if (s.tag == UNDETVAR) {
     1.8 +            UndetVar uv = (UndetVar)s;
     1.9 +            if (uv.inst != null)
    1.10 +                return isSubtypeUnchecked(t, uv.inst, warn);
    1.11 +        }
    1.12          else if (!s.isRaw()) {
    1.13              Type t2 = asSuper(t, s.tsym);
    1.14              if (t2 != null && t2.isRaw()) {
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/generics/inference/6718364/T6718364.java	Fri Aug 08 17:38:20 2008 +0100
     2.3 @@ -0,0 +1,38 @@
     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 6718364
    2.30 + * @summary inference fails when a generic method is invoked with raw arguments
    2.31 + * @compile/ref=T6718364.out -XDstdout -XDrawDiagnostics -Xlint:unchecked T6718364.java
    2.32 + */
    2.33 +class T6718364 {
    2.34 +    class X<T> {}
    2.35 +
    2.36 +    public <T> void m(X<T> x, T t) {}
    2.37 +
    2.38 +    public void test() {
    2.39 +        m(new X<X<Integer>>(), new X());
    2.40 +    }
    2.41 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/generics/inference/6718364/T6718364.out	Fri Aug 08 17:38:20 2008 +0100
     3.3 @@ -0,0 +1,3 @@
     3.4 +T6718364.java:36:32: compiler.warn.prob.found.req: (- compiler.misc.unchecked.assign), T6718364.X, T6718364.X<java.lang.Integer>
     3.5 +T6718364.java:36:10: compiler.warn.unchecked.meth.invocation.applied: <T>m(T6718364.X<T>,T), T6718364, , T6718364.X<T6718364.X<java.lang.Integer>>,T6718364.X
     3.6 +2 warnings
     3.7 \ No newline at end of file

mercurial