Misleading compile error - regression
Sven Reimers
sven.reimers at gmail.com
Fri Apr 27 13:01:35 UTC 2018
Hi all,
using a compiler from 9, 10, 11 the following code
package issue;
public class A {
public static interface I {
public void m(String s);
}
public void add (I i) {}
public static void main(String[] args) {
A a = new A();
a.add(() -> {});
}
}
results in
... issue/A.java:2: error: incompatible types: incompatible parameter types
in lambda expression
public class A {
Note: Some messages have been simplified; recompile with -Xdiags:verbose to
get full output
1 error
With -Xdiags:verbose the message is correct
... issue/A.java:12: error: method add in class A cannot be applied to
given types;
a.add(() -> {});
required: I
found: ()->{ }
reason: argument mismatch; incompatible parameter types in lambda
expression
1 error
-> Look at the difference in the line number.
Using JDK 8 everything works as expected (correct line number without
-Xdiags:verbose).
I assume this is not the desired behavior.
Is this already known? Any issue in JBS already?
Thanks
Sven
--
Sven Reimers
* Senior Expert Software Architect
* Java Champion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20180427/b28ddbb4/attachment.html>
More information about the compiler-dev
mailing list