Method reference doesn't work correctly
Srikanth
srikanth.adayapalam at oracle.com
Wed May 6 23:57:30 UTC 2020
Thanks for the test case, I have raised
https://bugs.openjdk.java.net/browse/JDK-8244558
(Did you mean to send it to valhalla-dev ?)
Thanks
Srikanth
On 07/05/20 3:55 am, Remi Forax wrote:
> Hi all,
> the inference of method reference doesn't work properly
>
> @__inline__ static class Foo {
> int x;
> Foo(int x) { this.x = x; }
> }
>
> static void m(Foo foo) {
> System.out.println("inline");
> }
> static void m(Foo.ref foo) {
> System.out.println("ref");
> }
>
> public static void main(String[] args) {
> var list = List.of(new Foo(3));
> list.forEach(e -> m(e));
> list.forEach(Foo::m);
> }
>
>
> Hello.java:19: error: invalid method reference
> list.forEach(Foo::m);
> ^
> cannot find symbol
> symbol: method m(T)
> location: class Foo
> where T is a type-variable:
> T extends Object declared in interface Iterable
>
> regards,
> Rémi
More information about the amber-dev
mailing list