Skip to content

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

Merged

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Jul 29, 2019

@nicolasstucki nicolasstucki requested a review from liufengyun July 29, 2019 09:57
@nicolasstucki nicolasstucki force-pushed the contextualize-type-splices branch from c90d288 to 58427a5 Compare July 29, 2019 11:33
@nicolasstucki nicolasstucki self-assigned this Jul 29, 2019
@nicolasstucki nicolasstucki force-pushed the contextualize-type-splices branch from 58427a5 to bff3dd7 Compare July 30, 2019 09:29
@nicolasstucki nicolasstucki marked this pull request as ready for review July 30, 2019 11:18
Copy link
Contributor

@liufengyun liufengyun left a 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)
Copy link
Contributor

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.

Copy link
Contributor Author

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

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.

Copy link
Contributor Author

@nicolasstucki nicolasstucki Jul 31, 2019

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.

@nicolasstucki nicolasstucki merged commit c67b6c9 into scala:master Jul 31, 2019
@nicolasstucki nicolasstucki deleted the contextualize-type-splices branch July 31, 2019 05:31
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.

2 participants