8043926: javac, code valid in 7 is not compiling for 8

Tue, 22 Jul 2014 13:21:50 +0100

author
mcimadamore
date
Tue, 22 Jul 2014 13:21:50 +0100
changeset 2545
64dc6333e6dc
parent 2544
91e9834baff2
child 2547
08c12757a1c9

8043926: javac, code valid in 7 is not compiling for 8
Summary: type-containment doesn't handle inference variables correctly
Reviewed-by: vromero, dlsmith

src/share/classes/com/sun/tools/javac/code/Types.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/inference/8043926/T8043926.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Jul 21 10:45:40 2014 -0400
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Jul 22 13:21:50 2014 +0100
     1.3 @@ -1305,7 +1305,8 @@
     1.4                  UndetVar undetvar = (UndetVar)t;
     1.5                  WildcardType wt = (WildcardType)s.unannotatedType();
     1.6                  switch(wt.kind) {
     1.7 -                    case UNBOUND: //similar to ? extends Object
     1.8 +                    case UNBOUND:
     1.9 +                        break;
    1.10                      case EXTENDS: {
    1.11                          Type bound = wildUpperBound(s);
    1.12                          undetvar.addBound(InferenceBound.UPPER, bound, this);
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/generics/inference/8043926/T8043926.java	Tue Jul 22 13:21:50 2014 +0100
     2.3 @@ -0,0 +1,43 @@
     2.4 +/*
     2.5 + * Copyright (c) 2014, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +/**
    2.28 + * @test
    2.29 + * @bug 8043926
    2.30 + * @summary javac, code valid in 7 is not compiling for 8
    2.31 + * @compile T8043926.java
    2.32 + */
    2.33 +class T8043926 {
    2.34 +    interface Iface<T1> {}
    2.35 +
    2.36 +    static class Impl implements Iface<Impl> {}
    2.37 +
    2.38 +    static class Acceptor<T2 extends Iface<T2>> {
    2.39 +        public Acceptor(T2 obj) {}
    2.40 +    }
    2.41 +
    2.42 +    void test(Impl impl) {
    2.43 +        Acceptor<?> acceptor1 = new Acceptor<>(impl);
    2.44 +        Acceptor<? extends Object> acceptor2 = new Acceptor<>(impl);
    2.45 +    }
    2.46 +}

mercurial