mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-11 22:19:43 +00:00
8020804: javac crashes when speculative attribution infers intersection type with array component
Assertion is causing javac to crash because of lack of support for arrays in intersection types Reviewed-by: jjg
This commit is contained in:
parent
2030148ec2
commit
67362236e8
@ -620,7 +620,9 @@ public class Types {
|
||||
* (ii) perform functional interface bridge calculation.
|
||||
*/
|
||||
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);
|
||||
Type descType = findDescriptorType(targets.head);
|
||||
ClassSymbol csym = new ClassSymbol(cflags, name, env.enclClass.sym.outermostClass());
|
||||
|
||||
@ -2970,7 +2970,9 @@ public class Attr extends JCTree.Visitor {
|
||||
//check that functional interface class is well-formed
|
||||
ClassSymbol csym = types.makeFunctionalInterfaceClass(env,
|
||||
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 {
|
||||
CAPTURED(InferenceBound.UPPER) {
|
||||
@Override
|
||||
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
|
||||
|
||||
46
langtools/test/tools/javac/lambda/8020804/T8020804.java
Normal file
46
langtools/test/tools/javac/lambda/8020804/T8020804.java
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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));
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user