diff --git a/src/share/classes/com/sun/tools/javac/comp/Infer.java b/src/share/classes/com/sun/tools/javac/comp/Infer.java index 216cf3cad71bd02bfba9258bb2606f2d0e33295c..fb61b61b8b0246c76bb896ee9be47667c75a3e80 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java @@ -1216,7 +1216,7 @@ public class Infer { * created, effectively replacing the original cyclic nodes. */ void initNodes() { - ArrayList nodes = new ArrayList(); + nodes = new ArrayList(); for (Type t : inferenceContext.restvars()) { nodes.add(new Node(t)); } @@ -1235,7 +1235,7 @@ public class Infer { } } } - this.nodes = new ArrayList(); + ArrayList acyclicNodes = new ArrayList(); for (List conSubGraph : GraphUtils.tarjan(nodes)) { if (conSubGraph.length() > 1) { Node root = conSubGraph.head; @@ -1244,8 +1244,9 @@ public class Infer { notifyUpdate(n, root); } } - this.nodes.add(conSubGraph.head); + acyclicNodes.add(conSubGraph.head); } + nodes = acyclicNodes; } /** diff --git a/test/tools/javac/lambda/TargetType65.java b/test/tools/javac/lambda/TargetType65.java new file mode 100644 index 0000000000000000000000000000000000000000..62248488a6f66958641a243885ff85769deff626 --- /dev/null +++ b/test/tools/javac/lambda/TargetType65.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8008723 + * @summary Graph Inference: bad graph calculation leads to assertion error + * @compile TargetType65.java + */ +class TargetType65 { + interface Predicate { + boolean accepts(X x); + } + + static class Optional { + public boolean isPresent() { return false; } + public static Optional empty() { return null; } + } + + interface Supplier { + X make(); + } + + static class Sink { } + + static class SubSink extends Sink> { } + + static class Tester { + public static Tester> makeRef() { + return new Tester<>(Optional.empty(), Optional::isPresent, SubSink::new); + } + + private Tester(O emptyValue, + Predicate presentPredicate, + Supplier> sinkSupplier) { + } + } +}