提交 d3042f3a 编写于 作者: M mcimadamore

8019480: Javac crashes when method is called on a type-variable receiver from lambda expression

Summary: Logic for shortcircuiting speculative attribution doesn't handle type-variable receivers
Reviewed-by: jjg, vromero
上级 c9c7c2cd
......@@ -941,6 +941,10 @@ public class DeferredAttr extends JCTree.Visitor {
attribSpeculative(rec, env, attr.unknownTypeExprInfo).type :
env.enclClass.sym.type;
while (site.hasTag(TYPEVAR)) {
site = site.getUpperBound();
}
ListBuffer<Type> args = ListBuffer.lb();
for (int i = 0; i < tree.args.length(); i ++) {
args.append(Type.noType);
......
/*
* @test /nodynamiccopyright/
* @bug 8019480
* @summary Javac crashes when method is called on a type-variable receiver from lambda expression
* @author Maurizio Cimadamore
* @compile/fail/ref=T8019480.out -XDrawDiagnostics T8019480.java
*/
import java.util.*;
class T8019480<U> {
interface Predicate<T> {
void m(T t);
}
interface Stream<T> {
void forEach(Predicate<T> pt);
}
void test(U current, Stream<U> stream) {
List<U> list3 = new ArrayList<>();
stream.forEach(i -> list3.add(current.clone()));
}
}
T8019480.java:21:46: compiler.err.report.access: clone(), protected, java.lang.Object
T8019480.java:21:34: compiler.err.cant.apply.symbols: kindname.method, add, java.lang.Object,{(compiler.misc.inapplicable.method: kindname.method, java.util.Collection, add(U), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Object, U))),(compiler.misc.inapplicable.method: kindname.method, java.util.List, add(U), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Object, U))),(compiler.misc.inapplicable.method: kindname.method, java.util.List, add(int,U), (compiler.misc.arg.length.mismatch))}
2 errors
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册