-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Contextualize type splices #6958
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
Contextualize type splices #6958
Conversation
c90d288
to
58427a5
Compare
58427a5
to
bff3dd7
Compare
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.
LGTM
@@ -19,5 +19,6 @@ object Unpickler { | |||
/** Unpickle `repr` which represents a pickled `Type` tree, | |||
* replacing splice nodes with `args` | |||
*/ | |||
def unpickleType[T](repr: Pickled, args: Seq[Seq[Any] => Type[_]]): Type[T] = new TastyType[T](repr, args) | |||
def unpickleType[T](repr: Pickled, args: Seq[Seq[Any] => Type[_]]): given QuoteContext => Type[T] = new TastyType[T](repr, args) |
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.
Just curious, what's the recommended practice to use given
: as parameters or contextual function types. Semantically the two are equivalent, and performance-wise they should be almost the same due to the optimization for implicit functions via direct methods.
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.
Here the desison was taken to have the symmetry between the quote and splices. The splice takes a contextual function, therefore the quote returns a contextual function. In this particular case, the alignment also helped to implement the quo/splice cancellation.
@@ -1,6 +1,7 @@ | |||
import scala.quoted._ | |||
|
|||
object Test { | |||
given as QuoteContext = ??? |
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.
It's not obvious to me why this is needed, given that all implicits are available and type check, and there are no quotes nor splices.
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.
The calls to a
and b
synesize some quoted types '[...]
, those require a context.
Change this line https://github.com/lampepfl/dotty/pull/6958/files#diff-78442038b1a8047647ef95723ef2a21bR22 and handle it in the compiler