8175790: field JCVariableDecl.vartype can't be null after post attribution analysis

Reviewed-by: mcimadamore
This commit is contained in:
Vicente Romero 2017-03-03 09:58:11 -08:00
parent 6a7ffcd667
commit e94e5d35bf
3 changed files with 36 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2017, 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
@ -4965,6 +4965,9 @@ public class Attr extends JCTree.Visitor {
that.sym = new VarSymbol(0, that.name, that.type, syms.noSymbol);
that.sym.adr = 0;
}
if (that.vartype == null) {
that.vartype = make.Erroneous();
}
super.visitVarDef(that);
}

View File

@ -0,0 +1,29 @@
/*
* @test /nodynamiccopyright/
* @bug 8175790
* @summary field JCVariableDecl.vartype can't be null after post attribution analysis
* @compile/fail/ref=NPEDueToErroneousLambdaTest.out -XDrawDiagnostics NPEDueToErroneousLambdaTest.java
*/
import java.util.List;
import java.util.function.Function;
public abstract class NPEDueToErroneousLambdaTest {
interface R {}
interface A {}
interface S {}
abstract <I, O> Function<I, O> p(final Function<I, O> function);
abstract <I, O> List<O> t(Function<? super I, ? extends O> function);
public void f() {
t(p(new Function<A, Object>() {
public List<Object> apply(A a) throws Exception {
return t((Function<R, S>)input -> {
return t(p((Function<Boolean, S>) i -> null), null);
});
}
}));
}
}

View File

@ -0,0 +1,3 @@
NPEDueToErroneousLambdaTest.java:22:33: compiler.err.override.meth.doesnt.throw: (compiler.misc.cant.implement: apply(NPEDueToErroneousLambdaTest.A), compiler.misc.anonymous.class: NPEDueToErroneousLambdaTest$1, apply(T), java.util.function.Function), java.lang.Exception
NPEDueToErroneousLambdaTest.java:24:32: compiler.err.cant.apply.symbol: kindname.method, t, java.util.function.Function<? super I,? extends O>, java.util.function.Function<java.lang.Boolean,NPEDueToErroneousLambdaTest.S>,compiler.misc.type.null, kindname.class, NPEDueToErroneousLambdaTest, (compiler.misc.infer.arg.length.mismatch: I,O)
2 errors