6569789: Compiler test lang/TYPE/type153/type15304/type15304.html fails since jdk7 b05

Wed, 02 Apr 2008 11:20:52 +0100

author
mcimadamore
date
Wed, 02 Apr 2008 11:20:52 +0100
changeset 17
6e4cefcce80a
parent 16
058bdd3ca02e
child 18
aeaa0f482b28

6569789: Compiler test lang/TYPE/type153/type15304/type15304.html fails since jdk7 b05
Summary: improved glb on type-inference
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/comp/Infer.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/inference/6569789/T6569789.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Mar 20 08:44:18 2008 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Apr 02 11:20:52 2008 +0100
     1.3 @@ -157,6 +157,19 @@
     1.4                      if (isSubClass(bs.head, that.hibounds))
     1.5                          that.inst = types.fromUnknownFun.apply(bs.head);
     1.6                  }
     1.7 +                if (that.inst == null) {
     1.8 +                    int classCount = 0, interfaceCount = 0;
     1.9 +                    for (Type t : that.hibounds) {
    1.10 +                        if (t.tag == CLASS) {
    1.11 +                            if (t.isInterface())
    1.12 +                                interfaceCount++;
    1.13 +                            else
    1.14 +                                classCount++;
    1.15 +                        }
    1.16 +                    }
    1.17 +                    if ((that.hibounds.size() == classCount + interfaceCount) && classCount == 1)
    1.18 +                        that.inst = types.makeCompoundType(that.hibounds);
    1.19 +                }
    1.20                  if (that.inst == null || !types.isSubtypeUnchecked(that.inst, that.hibounds, warn))
    1.21                      throw ambiguousNoInstanceException
    1.22                          .setMessage("no.unique.maximal.instance.exists",
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/generics/inference/6569789/T6569789.java	Wed Apr 02 11:20:52 2008 +0100
     2.3 @@ -0,0 +1,44 @@
     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     6569789
    2.30 + * @summary Compiler test lang/TYPE/type153/type15304/type15304.html fails since jdk7 b05
    2.31 + * @compile T6569789.java
    2.32 + */
    2.33 +
    2.34 +class C {}
    2.35 +interface I {}
    2.36 +interface I1 {}
    2.37 +interface I2 {}
    2.38 +class CT extends C implements I, I1, I2 {}
    2.39 +
    2.40 +public class T6569789 {
    2.41 +    public static void m() {
    2.42 +        CT ct = new CT();
    2.43 +        testMethod(ct);
    2.44 +    }
    2.45 +
    2.46 +    static <W extends C & I & I1 & I2, T extends W> void testMethod(T t) {}
    2.47 +}
    2.48 \ No newline at end of file

mercurial