Skip to content

Encode unpickle call directly on context #10238

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

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Nov 9, 2020

This removes the internal methods PickledQuoted.{unpickleExpr, unpickleType}

@nicolasstucki
Copy link
Contributor Author

Part of #10222

@nicolasstucki nicolasstucki marked this pull request as ready for review November 9, 2020 13:00
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.

Otherwise, LGTM

val tree = PickledQuotes.unpickleTerm(pickledQuote)(using reflect.rootContext)
new scala.internal.quoted.Expr(tree, hash)
new scala.internal.quoted.Expr(tree, hash).asInstanceOf[scala.quoted.Expr[T]]
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to me that the original type signature is better. By returning the type Expr[T], there are no guarantees.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, there are no guarantees. Calls to this method should only be inserted be the compiler.
The previous version added the cast after each call to this method, effectively having the same guaranties.

I will add some extra documentation to make it clear that no one should be calling this method directly. Currently, it is hidden from the user as it is defined in QuoteContextInteranal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general, all methods in QuoteContextInteranal should only be called by code generated by the compiler or something in the library.

@nicolasstucki nicolasstucki merged commit 42d5c26 into scala:master Nov 9, 2020
@nicolasstucki nicolasstucki deleted the encode-unpickle-call-directly-on-context branch November 9, 2020 15:54
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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.

3 participants