-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #4364: Try SAM type when no candidates are found #5717
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with a question to confirm my understanding
@@ -3,7 +3,7 @@ import collection._ | |||
object Test { | |||
def check(obj: AnyRef): Unit = { | |||
val bos = new ByteArrayOutputStream() | |||
val out = new ObjectOutputStream(println) // error | |||
val out = new ObjectOutputStream(println) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the overload is now resolved, but it's still a warning (OutputStream is not @FunctionalInterface
), right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you get:
6 | val out = new ObjectOutputStream(println)
| ^^^^^^^
|method println is eta-expanded even though java.io.OutputStream does not have the @FunctionalInterface annotation.
Oh, one more semi-related question to eta-expansion of 0-argument methods. Is #2570 (comment) still the intended spec? Especially this part:
does not seem to be implemented: We're discussing this over in scala/scala#6475. |
For overloading resolution, try a SAM type when no candidates are found.
Also, issue a warning when eta-expanding to a SAM type without a @FunctionalInterface
annotation.
Based on #4821