-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Changes to eta expansion #2701
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
Changes to eta expansion #2701
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! ❤️
Commit Messages
We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).
Please stick to these guidelines for commit messages:
- Separate subject from body with a blank line
- When fixing an issue, start your commit message with
Fix #<ISSUE-NBR>:
- Limit the subject line to 72 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line ("Added" instead of "Add")
- Wrap the body at 80 characters
- Use the body to explain what and why vs. how
adapted from https://chris.beams.io/posts/git-commit
Have an awesome day! ☀️
Seems dotty-bot got chatty again? |
It's turned quite passive aggressive lately! :) We'll look at remedying it! |
|
||
// Reasons NOT to eta expand: | ||
// - we reference a constructor | ||
// - we are in a patterm |
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.
Typo. Should be "pattern"
Implements another part of scala#2570
For neg/typedapply.scala we had an infinite sequence of eta-expansions, followed by `.apply` selections.
"Expected:" always came out empty: `[]`.
I overlooked that we actually have a `closure` extractor, which would do the job of `isClosure`, if we ever needed it.
The nightly build runs the sbt incremental compilation tests (that can be run by hand using sbt "sbt-dotty/scripted source-dependencies/*" but take a while to complete). The implicit-params test started failing after scala#2701 because B.scala contains: val y = x(3) which was supposed to fail when the implicit is not present but now succeeds with `y` getting the type `E => String`. We restore the failure by adding a type annotation to `y`
This implements the eta expansion parts of #2570, following the recommendations in my comment there:
After discussing this with @adriaanm, we are leaning towards the following compromise proposal for handling references to unapplied methods m:
If m has one or more parameters, we always eta expand
if m is nullary and the expected type is of the form () => T, we eta expand.
Based on #2691