Skip to content

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

Merged
merged 9 commits into from
Jun 23, 2017
Merged

Changes to eta expansion #2701

merged 9 commits into from
Jun 23, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jun 7, 2017

  • allow partial eta expansion
  • always eta expand if arity is >= 1

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

Copy link
Member

@dottybot dottybot left a 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:

  1. Separate subject from body with a blank line
  2. When fixing an issue, start your commit message with Fix #<ISSUE-NBR>:
  3. Limit the subject line to 72 characters
  4. Capitalize the subject line
  5. Do not end the subject line with a period
  6. Use the imperative mood in the subject line ("Added" instead of "Add")
  7. Wrap the body at 80 characters
  8. Use the body to explain what and why vs. how

adapted from https://chris.beams.io/posts/git-commit

Have an awesome day! ☀️

@odersky
Copy link
Contributor Author

odersky commented Jun 7, 2017

Seems dotty-bot got chatty again?

@smarter
Copy link
Member

smarter commented Jun 7, 2017

@odersky This is dotty-bot way of telling you that it doesn't like commit messages where the subject line ends with a '.', like 42cbf5c ;)

@felixmulder
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo. Should be "pattern"

@smarter smarter self-assigned this Jun 14, 2017
odersky added 7 commits June 14, 2017 16:53
For neg/typedapply.scala we had an infinite sequence of
eta-expansions, followed by `.apply` selections.
"Expected:" always came out empty: `[]`.
odersky added 2 commits June 14, 2017 16:56
I overlooked that we actually have a `closure` extractor, which would
do the job of `isClosure`, if we ever needed it.
@odersky odersky merged commit 0109fef into scala:master Jun 23, 2017
smarter added a commit to dotty-staging/dotty that referenced this pull request Jun 24, 2017
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`
@allanrenucci allanrenucci deleted the fix-#2570 branch December 14, 2017 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants