Skip to content

Inline and implicit matches #5392

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 17 commits into from
Nov 21, 2018
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Nov 5, 2018

Bring back inline and implicit matches in a typed setting.

Based on #5383.

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 ("Add" instead of "Added")
  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 odersky force-pushed the add-inline-matches branch 3 times, most recently from 1e89bcc to 39f8101 Compare November 8, 2018 13:27
@odersky
Copy link
Contributor Author

odersky commented Nov 8, 2018

This PR brings us roughly to feature parity with the previous rewrite method PR, minus the things one can only do when re-type-checking from scratch. I have listed things that still remain to be done as issues #5404 to #5409.

Going forward I will only have very limited time working on this. If we want to see this to a conclusion I need substantial help. I feel my time would be best spent helping others getting up to speed on this.

@milessabin
Copy link
Contributor

Count me in :-)

@odersky
Copy link
Contributor Author

odersky commented Nov 9, 2018

How should we go about reviewing? I realize it's difficult since it's a lot of code. On the other hand, most of that code is just a re-instantiation of what we already had before, so less urgent to review it again. Commits with mostly new stuff are: 70a5209, 571d1ba, df124be, 6848fac, 58d8e71, 36323a4, 3ef00b9.

Maybe just review those?

Copy link
Contributor

@nicolasstucki nicolasstucki left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

Introduce trees for inline and implicit matches
Just syntax and parsing, no interpretation yet.
Undoes:

 - Drop TransparentTyper (reverted from commit f6c440f)
Undoes:

 - Drop InlineIf and InlineMatch (reverted from commit 8ae9d6a)
 - Revert: Drop InlineIf and InlineMatch (reverted from commit 8ae9d6a)
 - Modify trees to not use a kind field in Match
Unapply methods can have `inline` flags. This enables reduceProjection to see
the methods right hand side. On the other hand, since `unapply` methods are not
applied hen used in patterns we do not classify them as inline methods. Consequently
they cannot contain inline matches or inline ifs.
 - perform implicit search in real Typer, not ReTyper
 - use existing symbols for match bindings
 - handle anonymous implicit bindings
 Some of them taken by reverting again:

  Remove remaining bits from untyped inliner (reverted from commit 35646ae)

# Conflicts:
#	compiler/src/dotty/tools/dotc/transform/FirstTransform.scala
Calls to primary constructors of NoInits classes are pure if prefix and
arguments are pure.
The `stageIt` switch determines whether specialization should take place during Typer or during Staging.
We should compile a test suite with both switch settings and compare

 - intermediate code after staging
 - intermesiate code after erasure
 - bytecode sizes
 - compile-time and runtime speed

That would let us decide which of the two schemes is preferable.
Reclassify previously invalidated typelevel tests

 - some of them work again
 - some of them can be turned into neg tests
 - the rest gets a note why they are invalid
This fixes some rebase breakage.
@odersky odersky merged commit eed948f into scala:master Nov 21, 2018
@allanrenucci allanrenucci deleted the add-inline-matches branch November 21, 2018 22:32
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