提交 567f352c 编写于 作者: M mcimadamore

8020804: javac crashes when speculative attribution infers intersection type with array component

Summary: Assertion is causing javac to crash because of lack of support for arrays in intersection types
Reviewed-by: jjg
上级 a8fa66b2
...@@ -620,7 +620,9 @@ public class Types { ...@@ -620,7 +620,9 @@ public class Types {
* (ii) perform functional interface bridge calculation. * (ii) perform functional interface bridge calculation.
*/ */
public ClassSymbol makeFunctionalInterfaceClass(Env<AttrContext> env, Name name, List<Type> targets, long cflags) { public ClassSymbol makeFunctionalInterfaceClass(Env<AttrContext> env, Name name, List<Type> targets, long cflags) {
Assert.check(targets.nonEmpty() && isFunctionalInterface(targets.head)); if (targets.isEmpty() || !isFunctionalInterface(targets.head)) {
return null;
}
Symbol descSym = findDescriptorSymbol(targets.head.tsym); Symbol descSym = findDescriptorSymbol(targets.head.tsym);
Type descType = findDescriptorType(targets.head); Type descType = findDescriptorType(targets.head);
ClassSymbol csym = new ClassSymbol(cflags, name, env.enclClass.sym.outermostClass()); ClassSymbol csym = new ClassSymbol(cflags, name, env.enclClass.sym.outermostClass());
......
...@@ -2970,7 +2970,9 @@ public class Attr extends JCTree.Visitor { ...@@ -2970,7 +2970,9 @@ public class Attr extends JCTree.Visitor {
//check that functional interface class is well-formed //check that functional interface class is well-formed
ClassSymbol csym = types.makeFunctionalInterfaceClass(env, ClassSymbol csym = types.makeFunctionalInterfaceClass(env,
names.empty, List.of(fExpr.targets.head), ABSTRACT); names.empty, List.of(fExpr.targets.head), ABSTRACT);
chk.checkImplementations(env.tree, csym, csym); if (csym != null) {
chk.checkImplementations(env.tree, csym, csym);
}
} }
} }
} }
......
...@@ -1240,7 +1240,8 @@ public class Infer { ...@@ -1240,7 +1240,8 @@ public class Infer {
CAPTURED(InferenceBound.UPPER) { CAPTURED(InferenceBound.UPPER) {
@Override @Override
public boolean accepts(UndetVar t, InferenceContext inferenceContext) { public boolean accepts(UndetVar t, InferenceContext inferenceContext) {
return !inferenceContext.free(t.getBounds(InferenceBound.UPPER, InferenceBound.LOWER)); return t.isCaptured() &&
!inferenceContext.free(t.getBounds(InferenceBound.UPPER, InferenceBound.LOWER));
} }
@Override @Override
......
/*
* 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 8020804
* @summary javac crashes when speculative attribution infers intersection type with array component
* @compile T8020804.java
*/
import java.util.*;
class T8020804 {
interface Supplier<D> {
D make();
}
void m(Object o) { }
void m(char[] c) { }
<C extends Collection<?>> C g(Supplier<C> sc) { return null; }
void test() {
m(g(LinkedList<Double>::new));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册