8055963: Inference failure with nested invocation

Tue, 26 May 2015 11:03:40 +0100

author
mcimadamore
date
Tue, 26 May 2015 11:03:40 +0100
changeset 2804
bacd3cbb4e5e
parent 2803
9538418d25b9
child 2805
f6c191e92814

8055963: Inference failure with nested invocation
Summary: Revise heuristics to force eager instantiation of return inference vars
Reviewed-by: vromero

src/share/classes/com/sun/tools/javac/comp/Infer.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/inference/8055963/T8055963.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu May 21 11:14:23 2015 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue May 26 11:03:40 2015 +0100
     1.3 @@ -315,11 +315,9 @@
     1.4              for (Type aLowerBound : from.getBounds(InferenceBound.LOWER)) {
     1.5                  for (Type anotherLowerBound : from.getBounds(InferenceBound.LOWER)) {
     1.6                      if (aLowerBound != anotherLowerBound &&
     1.7 -                        commonSuperWithDiffParameterization(aLowerBound, anotherLowerBound)) {
     1.8 -                        /* self comment check if any lower bound may be and undetVar,
     1.9 -                         * in that case the result of this call may be a false positive.
    1.10 -                         * Should this be restricted to non free types?
    1.11 -                         */
    1.12 +                            !inferenceContext.free(aLowerBound) &&
    1.13 +                            !inferenceContext.free(anotherLowerBound) &&
    1.14 +                            commonSuperWithDiffParameterization(aLowerBound, anotherLowerBound)) {
    1.15                          return generateReferenceToTargetConstraint(tree, from, to,
    1.16                              resultInfo, inferenceContext);
    1.17                      }
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/generics/inference/8055963/T8055963.java	Tue May 26 11:03:40 2015 +0100
     2.3 @@ -0,0 +1,41 @@
     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.  Oracle designates this
    2.11 + * particular file as subject to the "Classpath" exception as provided
    2.12 + * by Oracle in the LICENSE file that accompanied this code.
    2.13 + *
    2.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.17 + * version 2 for more details (a copy is included in the LICENSE file that
    2.18 + * accompanied this code).
    2.19 + *
    2.20 + * You should have received a copy of the GNU General Public License version
    2.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.23 + *
    2.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.25 + * or visit www.oracle.com if you need additional information or have any
    2.26 + * questions.
    2.27 + */
    2.28 +
    2.29 +/**
    2.30 + * @test
    2.31 + * @bug 8055963
    2.32 + * @summary Inference failure with nested invocation
    2.33 + * @compile T8055963.java
    2.34 + */
    2.35 +class T8055963 {
    2.36 +
    2.37 +    static class C<T> {}
    2.38 +
    2.39 +    <T> T choose(T first, T second) { return null; }
    2.40 +
    2.41 +    void test() {
    2.42 +        C<String> cs = choose(new C<String>(), new C<>());
    2.43 +    }
    2.44 +}

mercurial