Skip to content

java.util.function.Consumer not working with lambda #12380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AugustNagro opened this issue May 8, 2021 · 2 comments
Closed

java.util.function.Consumer not working with lambda #12380

AugustNagro opened this issue May 8, 2021 · 2 comments

Comments

@AugustNagro
Copy link
Contributor

Compiler version

3.0.0-RC3

Minimized code

val l = java.util.List.of(1, 2, 3)
l.forEach(x => println(x))

Output

[error] 4 |  l.forEach(x => println(x))
[error]   |              ^
[error]   |object creation impossible, since def accept(x$0: T): Unit in trait Consumer in package java.util.function is not defined 
[error]   |(Note that
[error]   | parameter T in def accept(x$0: T): Unit in trait Consumer in package java.util.function does not match
[error]   | parameter Int in final def accept(x: Int): Unit in anonymous class Object with java.util.function.Consumer[? >: Int] {...}
[error]   | )

This works:

val l = java.util.List.of(1, 2, 3)
val consumer: java.util.function.Consumer[Int] = x => println(x)
l.forEach(consumer)

Maybe related to @smarter's PR #12131?

@smarter
Copy link
Member

smarter commented May 8, 2021

Works fine on master (though I don't know which PR is responsible for that since #12131 was backported).

@smarter smarter closed this as completed May 8, 2021
@AugustNagro
Copy link
Contributor Author

AugustNagro commented May 8, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants