Type the quoted patterns as precisely as possible#6742
Merged
odersky merged 2 commits intoscala:masterfrom Jul 8, 2019
Merged
Conversation
546cea3 to
ecee17d
Compare
325a113 to
9875979
Compare
In a pattern match where the contents of the quote are statically known we want to propagate the
type inside the pattern the the binding. For example `e` will not only be an `Expr[T]` but also
an `Expr[Some[Int]]`.
```scala
(s: Expr[T]) match {
case e @ '{ Some($x: Int) } =>
// e: Expr[T & Some[Int]]
// x: Expr[Int]
}
```
If the expression in the pattern contains a spliced expression, possibly typed, we also need to propagate the
type of the scrutinee down into the pattern. For example `x` will not only be an `Expr[Boolean]` but also
an `Expr[T]`.
```scala
(s: Expr[T]) match {
case e @ '{ $x: Boolean } =>
// e: Expr[T & Boolean]
// x: Expr[T & Boolean]
}
```
9875979 to
1a1e8f6
Compare
odersky
approved these changes
Jul 8, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a pattern match where the contents of the quote are statically known we want to propagate the
type inside the pattern the the binding. For example
ewill not only be anExpr[T]but alsoan
Expr[Some[Int]].If the expression in the pattern contains a spliced expression, possibly typed, we also need to propagate the
type of the scrutinee down into the pattern. For example
xwill not only be anExpr[Boolean]but alsoan
Expr[T].