Skip to content
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

Replace `delegate match` with `summonFrom`. #7201

Merged
merged 12 commits into from Sep 12, 2019

Conversation

@odersky
Copy link
Contributor

odersky commented Sep 12, 2019

Instead of having a separate syntactic construct (latest incarnation: delegate match), provide
a special method summonFrom in scala.compiletime.

delegate match { 
  case ev_1: TC_1 => e_1
  ...
  case ev_n: TC_n => e_n
}

becomes

summonFrom { 
  case given ev_1: TC_1 => e_1
  ...
  case given ev_n: TC_n => e_n
}

summonFrom is currently implemented by compiler magic. It could be implemented as a macro if we introduce an additional way to control when inline methods expand. See the comment in Applications.scala.

Based on #7194.

odersky added 11 commits Sep 1, 2019
Change contextual docs to reflect three changes to `given` syntax:

 - put `given` inside the parentheses of parameters and arguments, as was suggested by @smarter.
 - change given import syntax to make `given` an import selector
 - change `the` to `theGiven`.

All of these should discussed in separate issues.
Following the discussion in #7151, choose `:` instead of `as` for given clauses.
Also: Allow inline givens to be whitebox
Syntax:

    given x: T

Allowed anywhere a pattern is allowed. This is useful in for expressions
and as a replacement of given matches, to name just two cases.
Drop `delegate match` and `given match`. They are replaced by `summonFrom`.
@odersky odersky changed the title replace `delegate match` with `summonFrom`. Replace `delegate match` with `summonFrom`. Sep 12, 2019
@milessabin

This comment has been minimized.

Copy link
Contributor

milessabin commented Sep 12, 2019

I'll update the shapeless-3 branch in the community build as soon as there's a nightly with these changes.

@odersky

This comment has been minimized.

Copy link
Contributor Author

odersky commented Sep 12, 2019

@milessabin How do we proceed with the bootstrap? Here's one way I see would work, but maybe there's something simpler:

  1. I roll everything up to 2b8ba68 into #7194 and we merge that first. That gives us summonFrom as well as delegate match.
  2. You update shapeless in the CB once (1) is in the nightly.
  3. We merge this PR once (2) is merged.

Should we do it like this?

@odersky odersky force-pushed the dotty-staging:add-summonFrom branch from 0a0e1b8 to b049b77 Sep 12, 2019
@milessabin

This comment has been minimized.

Copy link
Contributor

milessabin commented Sep 12, 2019

Should we do it like this?

Or simpler ... just let shapeless break in the community build and I'll fix it up afterwards.

@odersky

This comment has been minimized.

Copy link
Contributor Author

odersky commented Sep 12, 2019

I was told by @nicolasstucki we can't get a nightly anymore if the CB breaks. So we'll do it in steps.

@odersky

This comment has been minimized.

Copy link
Contributor Author

odersky commented Sep 12, 2019

@milessabin I was puzzled why the community build passed, even though delegate match is gone. It seems shapeless still uses implicit match, right? That will be the next to go but in a different PR. So we can get this one in if I get a review thumbs up and then it's over to you for the shapeless update.

@odersky odersky requested a review from biboudis Sep 12, 2019
@odersky

This comment has been minimized.

Copy link
Contributor Author

odersky commented Sep 12, 2019

@biboudis This is actually a stack for 3 PR's:

#7150: Reference docs only, changes the given syntax
#7194: Allow given in patterns
#7201: This PR

I believe they are best reviewed in order, but it's easiest if we do fixes and merges just on this PR.

@milessabin

This comment has been minimized.

Copy link
Contributor

milessabin commented Sep 12, 2019

It seems shapeless still uses implicit match

Oh! Yes ... I went straight from implicit to given and never changed the matches over.

Yup, go ahead and merge this. Do you want to do the separate PR that removes implicit match right away, or will there be a new nightly including this PR before then?

@milessabin milessabin self-requested a review Sep 12, 2019
@odersky

This comment has been minimized.

Copy link
Contributor Author

odersky commented Sep 12, 2019

Yup, go ahead and merge this. Do you want to do the separate PR that removes implicit match right away, or will there be a new nightly including this PR before then?

We'll do a new nightly before.

@odersky odersky merged commit 60c3a12 into lampepfl:master Sep 12, 2019
2 checks passed
2 checks passed
CLA User signed CLA
Details
continuous-integration/drone/pr Build is passing
Details
@odersky odersky deleted the dotty-staging:add-summonFrom branch Sep 12, 2019
@anatoliykmetyuk anatoliykmetyuk added this to the 0.19 Tech Preview milestone Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.