-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Unencode quote and splice trees #17342
Conversation
This field is no longer used and can be removed. Removing it is backwards compatible with 3.0 and later releases.
Closes scala#6991
cde31be
to
cdd5ffb
Compare
@@ -398,6 +398,9 @@ trait TypeAssigner { | |||
.appliedTo(defn.QuotesClass.typeRef, defn.QuotedExprClass.typeRef.appliedTo(tpt.tpe)) | |||
tree.withType(lambdaType) | |||
|
|||
def assignType(tree: untpd.SplicedExpr, tpt: Tree)(using Context): SplicedExpr = | |||
tree.withType(tpt.tpe) |
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.
If tpt is always the same as the type of the node, and if tpt is always EmptyTree in untyped trees, then it shouldn't be necessary and can be removed (possibly using promote
in TreeChecker to retype it).
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.
I was wondering how the tpt
could be removed. I will try that.
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.
We currently use the tpt
in the staging
/splicing
phases to set staged healed types for quotes and splices. I did not manage to remove it without breaking something in those phases.
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.
I did not manage to remove it without breaking something in those phases.
We have other phases where we transform types of trees like https://github.com/lampepfl/dotty/blob/main/compiler/src/dotty/tools/dotc/transform/ElimErasedValueType.scala, does that not work here? Maybe I can have a look if you show me what the issues you ran into were.
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.
I managed to remove the tpt
.
/** A tree representing a quote `'{ expr } | ||
* | ||
* @param expr The tree that was quoted | ||
* @param tpt The type of the tree that was quoted, |
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.
How does this differ from expr.tpe?
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.
In the staging
phase we use tpt
to store the healed version of the type. This cannot be recomputed trivially from expr.tpe
.
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.
Now staging uses expr.tpe
to store the new version of type.
To transform quotes and splices in inline methods.
Co-authored-by: Guillaume Martres <[email protected]>
f4dd16f
to
9214daa
Compare
I updated the check-files in 95c39bc to fix the CI failures. |
Closes scala#18059 Probably fixed by scala#17342
We currently use the
Quote
andSplice
ASTs for untyped quotes and splices. Then when we type them we encode them intoscala.quoted.runtime.Expr.{quote,splice,nestedSplice}
. This non-semantic representation if fragile and the source of many past bug. In this PR we change the internal representation of quotes and splices to use theQuote
andSplice
ASTs as typed trees.The core of this change in the AST representation and how we type them in
QuotesAndSplices
. Other changes consist in adapting the code from one representation to the other.splice
in all cases. The additionalQuotes
innestedSplice
is not used.