Skip to content

Unencode quote and splice trees #17342

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
merged 46 commits into from
May 2, 2023
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c2f6362
Rename `Spliced` to `SplicedExpr`
nicolasstucki Apr 21, 2023
938d3ae
Split `Quoted` extractor into `QuotedExpr` and `QuotedTypeOf`
nicolasstucki Apr 21, 2023
b7ca9b1
Split `transformQuotation` into `transformQuotedExpr` and `transformQ…
nicolasstucki Apr 21, 2023
deb03a7
Add `QuotedExpr` to encode quotes directly in the AST
nicolasstucki Apr 21, 2023
b7a7227
Add `SplicedExpr` to encode splices directly in the AST
nicolasstucki Apr 21, 2023
fe64a3e
Remove splice outer quotes context
nicolasstucki Apr 25, 2023
161ef49
Rename `SplicedExpr.{spliced=>expr}`
nicolasstucki Apr 25, 2023
cf30d30
Use QuotedExpr instead of Quote trees
nicolasstucki Apr 25, 2023
f0d758b
Use SplicedExpr instead of Splice trees
nicolasstucki Apr 25, 2023
c6adab8
Move typedQuotedExpr/typedSplicedExpr to QuotesAndSplices
nicolasstucki Apr 25, 2023
3a045c4
Rename QuotedExpr to Quote and SplicedExpr to Splice
nicolasstucki Apr 25, 2023
76d0daf
Add documentation
nicolasstucki Apr 25, 2023
75bacdb
Backwards compatibility support for quotes and splice in reflection API
nicolasstucki Apr 25, 2023
0e6dc2e
Add regression test
nicolasstucki Apr 25, 2023
cdd5ffb
Adapt REPL test output
nicolasstucki Apr 26, 2023
04f020f
Remove `Splice.isInBraces`
nicolasstucki Apr 27, 2023
35db4a1
Move Quote/Splice retyping into ReTyper
nicolasstucki Apr 27, 2023
1ef7f59
Add documentation
nicolasstucki Apr 27, 2023
687d06e
Transform Quote/Splice in MiniPhase
nicolasstucki Apr 27, 2023
1f62049
Add TODOs and fix typos
nicolasstucki Apr 28, 2023
5ae7861
Remove `tpt` from `Quote`
nicolasstucki Apr 28, 2023
3976d06
Remove `tpt` from `Splice`
nicolasstucki Apr 28, 2023
d4b2f09
Rename `Quote.{expr=>body}`
nicolasstucki Apr 28, 2023
35408ec
Fix staging level tracking in Transformer
nicolasstucki Apr 28, 2023
e73eab7
Cleanup unnecessary staging level updates
nicolasstucki Apr 28, 2023
e06b0f9
Use `Quote to encode `Type.of` in the `staging phase`
nicolasstucki May 1, 2023
095a7f1
Remove state from TreeMapWithStages
nicolasstucki May 1, 2023
10cbc60
Fix wrong staging level error message
nicolasstucki May 1, 2023
3097f49
Simplify quoted type transformation in CrossStageSafety
nicolasstucki May 1, 2023
8a9871f
Simplify Quote/Splice transformations in CrossStageSafety
nicolasstucki May 1, 2023
966835b
Deduplicate code that transforms `Quote`, `Splice`, `Type.of`
nicolasstucki May 1, 2023
95c39bc
Cleanup
nicolasstucki May 1, 2023
0ca6066
Remove redundant case
nicolasstucki May 1, 2023
e3735fa
Refactor
nicolasstucki May 1, 2023
6956c43
Refactor quote cancellation logic
nicolasstucki May 1, 2023
859f6e6
Remove unnecessary quotation level change
nicolasstucki May 1, 2023
e4ddc88
Add missing change of staging level
nicolasstucki May 1, 2023
7e8d2b1
Simplify macroDependencies using level from context
nicolasstucki May 1, 2023
a3c657b
Fix typo
nicolasstucki May 1, 2023
be3cd48
Refactor use of Quote
nicolasstucki May 1, 2023
7bd7c92
Do not traverse type trees to find inline method calls
nicolasstucki May 1, 2023
b991b40
Remove post-condition that is already checked by Staging
nicolasstucki May 1, 2023
e611139
Refactor quote pickling case
nicolasstucki May 1, 2023
37200be
Cleanup
nicolasstucki May 1, 2023
e75cafe
Remove unnecessary widening
nicolasstucki May 1, 2023
9214daa
Apply suggestions from code review
nicolasstucki May 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -677,23 +677,41 @@ object Trees {
override def isType = expansion.isType
}

/** A tree representing a quote `'{ expr }
/** A tree representing a quote `'{ expr }`
* `Quote`s are created by the `Parser` with an empty `tpt`. In typer
* they can be typed as a `Quote` with a known `tpt` or desugared and
* typed as a quote pattern.
*
* `Quotes` are checked transformed in the `staging`, `splicing` and `pickleQuotes`
* phases. After `pickleQuotes` phase, the only quotes that exist are in `inline`
* methods. These are dropped when we remove the inline method implementations.
*
* The `tpt` will be transformed in `staging` and used in `pickleQuotes` to create the
* pickled representation of the quote.
*
* @param expr The tree that was quoted
* @param tpt The type of the tree that was quoted,
* EmptyTree if this tree comes from the parser.
* @param tpt The type of the tree that was quoted
*/
case class Quote[+T <: Untyped] private[ast] (expr: Tree[T], tpt: Tree[T])(implicit @constructorOnly src: SourceFile)
extends TermTree[T] {
type ThisTree[+T <: Untyped] = Quote[T]
}

/** A tree representing a splice `${ expr }`
*
* @param expr The tree that was spliced
* @param tpt The type of the tree that was spliced,
* EmptyTree if this tree comes from the parser.
*/
*
* `Splice`s are created by the `Parser` with an empty `tpt`. In typer
* they can be typed as a `Splice` with a known `tpt` or desugared and
* typed as a quote pattern holes.
*
* `Splice` are checked transformed in the `staging` and `splicing` phases.
* After `splicing` phase, the only quotes that exist are in `inline`
* methods. These are dropped when we remove the inline method implementations.
*
* The `tpt` will be transformed in `staging` and used in `splicing` to create `Hole`s.
*
* @param expr The tree that was spliced
* @param tpt The type of the spliced tree
*/
case class Splice[+T <: Untyped] private[ast] (expr: Tree[T], tpt: Tree[T])(implicit @constructorOnly src: SourceFile)
extends TermTree[T] {
type ThisTree[+T <: Untyped] = Splice[T]
Expand Down