8202372: Diagnostic with incorrect line info generated when compiling lambda expression
Add tree position to speculative lambda tree Reviewed-by: vromero, jlahoda
This commit is contained in:
parent
45aa655cd0
commit
7dc011ccca
@ -441,7 +441,7 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||
} else {
|
||||
stats.add((JCBlock)that.body);
|
||||
}
|
||||
JCBlock lambdaBlock = make.Block(0, stats.toList());
|
||||
JCBlock lambdaBlock = make.at(that.pos).Block(0, stats.toList());
|
||||
Env<AttrContext> localEnv = attr.lambdaEnv(that, env);
|
||||
try {
|
||||
localEnv.info.returnResult = resultInfo;
|
||||
|
45
test/langtools/tools/javac/lambda/8202372/T8202372.java
Normal file
45
test/langtools/tools/javac/lambda/8202372/T8202372.java
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8202372
|
||||
* @summary Diagnostic with incorrect line info generated when compiling lambda expression
|
||||
* @compile/fail/ref=T8202372.out -XDrawDiagnostics T8202372.java
|
||||
*/
|
||||
class T8202372 {
|
||||
|
||||
interface NonVoidFunc {
|
||||
String m();
|
||||
}
|
||||
|
||||
interface VoidFunc {
|
||||
void m();
|
||||
}
|
||||
|
||||
interface ParamFunc {
|
||||
void m(String s);
|
||||
}
|
||||
|
||||
public void addVoid(VoidFunc v) {}
|
||||
public void addNonVoid(NonVoidFunc nv) {}
|
||||
public void addParam(ParamFunc p) {}
|
||||
|
||||
void testVoid(T8202372 test) {
|
||||
test.addVoid(() -> "");
|
||||
test.addVoid(() -> { return ""; });
|
||||
test.addVoid(() -> { });
|
||||
test.addVoid(() -> { return; });
|
||||
}
|
||||
|
||||
void testNonVoid(T8202372 test) {
|
||||
test.addNonVoid(() -> "");
|
||||
test.addNonVoid(() -> { return ""; });
|
||||
test.addNonVoid(() -> { });
|
||||
test.addNonVoid(() -> { return; });
|
||||
}
|
||||
|
||||
void testParam(T8202372 test) {
|
||||
test.addParam(() -> {});
|
||||
test.addParam((String x) -> { });
|
||||
test.addParam((String x1, String x2) -> { });
|
||||
test.addParam((int x) -> { });
|
||||
}
|
||||
}
|
8
test/langtools/tools/javac/lambda/8202372/T8202372.out
Normal file
8
test/langtools/tools/javac/lambda/8202372/T8202372.out
Normal file
@ -0,0 +1,8 @@
|
||||
T8202372.java:26:13: compiler.err.cant.apply.symbol: kindname.method, addVoid, T8202372.VoidFunc, @22, kindname.class, T8202372, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.stat.expr.expected))
|
||||
T8202372.java:27:13: compiler.err.cant.apply.symbol: kindname.method, addVoid, T8202372.VoidFunc, @22, kindname.class, T8202372, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val)))
|
||||
T8202372.java:35:13: compiler.err.cant.apply.symbol: kindname.method, addNonVoid, T8202372.NonVoidFunc, @25, kindname.class, T8202372, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))
|
||||
T8202372.java:36:13: compiler.err.cant.apply.symbol: kindname.method, addNonVoid, T8202372.NonVoidFunc, @25, kindname.class, T8202372, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val)))
|
||||
T8202372.java:40:13: compiler.err.cant.apply.symbol: kindname.method, addParam, T8202372.ParamFunc, @23, kindname.class, T8202372, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))
|
||||
T8202372.java:42:13: compiler.err.cant.apply.symbol: kindname.method, addParam, T8202372.ParamFunc, @23, kindname.class, T8202372, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))
|
||||
T8202372.java:43:13: compiler.err.cant.apply.symbol: kindname.method, addParam, T8202372.ParamFunc, @23, kindname.class, T8202372, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))
|
||||
7 errors
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test /nodynamioccopyright/
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8200199
|
||||
* @summary javac suggests to use var even when var is used
|
||||
* @compile/fail/ref=T8200199.out -Werror -XDfind=local -XDrawDiagnostics T8200199.java
|
||||
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test /nodynamioccopyright/
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8177466
|
||||
* @summary Add compiler support for local variable type-inference
|
||||
* @compile -source 8 pkg/var.java
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* @test /nodynamioccopyright/
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8199194
|
||||
* @summary smoke test for --enabled-preview classreader support
|
||||
* @compile -XDforcePreview --enable-preview -source 11 Bar.java
|
||||
|
Loading…
x
Reference in New Issue
Block a user