8065800: javac, fix diagnostic position for statement-bodied lambdas
authorcushon
Thu, 05 Jan 2017 10:04:40 -0800
changeset 43030 a3d5b201d899
parent 43029 1cd1c816581e
child 43031 2d0b2f38225a
8065800: javac, fix diagnostic position for statement-bodied lambdas Reviewed-by: mcimadamore
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
langtools/test/tools/javac/lambda/MostSpecific09.java
langtools/test/tools/javac/lambda/MostSpecific09.out
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Wed Jan 04 18:33:20 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Jan 05 10:04:40 2017 -0800
@@ -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
@@ -1740,7 +1740,7 @@
         accept(ARROW);
 
         return token.kind == LBRACE ?
-            lambdaStatement(args, pos, pos) :
+            lambdaStatement(args, pos, token.pos) :
             lambdaExpression(args, pos);
     }
 
--- a/langtools/test/tools/javac/lambda/MostSpecific09.java	Wed Jan 04 18:33:20 2017 -0800
+++ b/langtools/test/tools/javac/lambda/MostSpecific09.java	Thu Jan 05 10:04:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 8029718
+ * @bug 8029718 8065800
  * @summary Should always use lambda body structure to disambiguate overload resolution
  * @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics --should-stop:at=ATTR --debug:verboseResolution=applicable,success MostSpecific09.java
  */
--- a/langtools/test/tools/javac/lambda/MostSpecific09.out	Wed Jan 04 18:33:20 2017 -0800
+++ b/langtools/test/tools/javac/lambda/MostSpecific09.out	Thu Jan 05 10:04:40 2017 -0800
@@ -2,7 +2,7 @@
 MostSpecific09.java:26:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)}
 MostSpecific09.java:27:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)}
 MostSpecific09.java:27:32: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)}
-MostSpecific09.java:28:13: compiler.err.lambda.body.neither.value.nor.void.compatible
+MostSpecific09.java:28:20: compiler.err.lambda.body.neither.value.nor.void.compatible
 MostSpecific09.java:28:9: compiler.err.cant.apply.symbols: kindname.method, foo, @682,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))}
 MostSpecific09.java:28:43: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)}
 MostSpecific09.java:29:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09
@@ -10,7 +10,7 @@
 MostSpecific09.java:30:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09
 MostSpecific09.java:32:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09
 MostSpecific09.java:33:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)}
-MostSpecific09.java:42:13: compiler.err.lambda.body.neither.value.nor.void.compatible
+MostSpecific09.java:42:20: compiler.err.lambda.body.neither.value.nor.void.compatible
 MostSpecific09.java:42:9: compiler.err.cant.apply.symbols: kindname.method, foo, @1131,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))}
 MostSpecific09.java:46:23: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)}
 MostSpecific09.java:49:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)}