8262095: NPE in Flow$FlowAnalyzer.visitApply: Cannot invoke getThrownTypes because tree.meth.type is null

Co-authored-by: Jan Lahoda <jlahoda@openjdk.org>
Co-authored-by: Vicente Romero <vromero@openjdk.org>
Reviewed-by: jlahoda
This commit is contained in:
Vicente Romero 2021-08-31 15:40:17 +00:00
parent e551852801
commit 75d987a0dd
3 changed files with 26 additions and 1 deletions
src/jdk.compiler/share/classes/com/sun/tools/javac/comp
test/langtools/tools/javac/lambda/8262095

@ -613,7 +613,10 @@ public class Attr extends JCTree.Visitor {
}
@Override
public void report(DiagnosticPosition pos, JCDiagnostic details) {
if (pt == Type.recoveryType) {
boolean needsReport = pt == Type.recoveryType ||
(details.getDiagnosticPosition() != null &&
details.getDiagnosticPosition().getTree().hasTag(LAMBDA));
if (needsReport) {
chk.basicHandler.report(pos, details);
}
}

@ -0,0 +1,20 @@
/*
* @test /nodynamiccopyright/
* @bug 8262095
* @summary Report diagnostics produced by incorrect lambdas
* @compile/fail/ref=T8262095.out -XDrawDiagnostics T8262095.java
*/
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Stream;
class T8262095 {
void f(Stream<Entry<Long, List<String>>> stream) {
stream.sorted(Entry.comparingByKey()
.thenComparing((Map.Entry<Long, List<String>> e) -> e.getValue().hashCode()))
.count();
}
}

@ -0,0 +1,2 @@
T8262095.java:17:42: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.inconvertible.types: java.util.function.Function<java.util.Map.Entry<java.lang.Long,java.util.List<java.lang.String>>,java.lang.Integer>, java.util.function.Function<? super java.util.Map.Entry<K,java.lang.Object>,? extends java.lang.Integer>))
1 error