-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Changes from 15 commits
c2f6362
938d3ae
b7ca9b1
deb03a7
b7a7227
fe64a3e
161ef49
cf30d30
f0d758b
c6adab8
3a045c4
76d0daf
75bacdb
0e6dc2e
cdd5ffb
04f020f
35db4a1
1ef7f59
687d06e
1f62049
5ae7861
3976d06
d4b2f09
35408ec
e73eab7
e06b0f9
095a7f1
10cbc60
3097f49
8a9871f
966835b
95c39bc
0ca6066
e3735fa
6956c43
859f6e6
e4ddc88
7e8d2b1
a3c657b
be3cd48
7bd7c92
b991b40
e611139
37200be
e75cafe
9214daa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -677,6 +677,29 @@ object Trees { | |
override def isType = expansion.isType | ||
} | ||
|
||
/** 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. In the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now staging uses |
||
* EmptyTree if this tree comes from the parser. | ||
*/ | ||
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. | ||
*/ | ||
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] | ||
def isInBraces: Boolean = span.end != expr.span.end | ||
smarter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/** A type tree that represents an existing or inferred type */ | ||
case class TypeTree[+T <: Untyped]()(implicit @constructorOnly src: SourceFile) | ||
extends DenotingTree[T] with TypTree[T] { | ||
|
@@ -1087,6 +1110,8 @@ object Trees { | |
type SeqLiteral = Trees.SeqLiteral[T] | ||
type JavaSeqLiteral = Trees.JavaSeqLiteral[T] | ||
type Inlined = Trees.Inlined[T] | ||
type Quote = Trees.Quote[T] | ||
type Splice = Trees.Splice[T] | ||
type TypeTree = Trees.TypeTree[T] | ||
type InferredTypeTree = Trees.InferredTypeTree[T] | ||
type SingletonTypeTree = Trees.SingletonTypeTree[T] | ||
|
@@ -1257,6 +1282,14 @@ object Trees { | |
case tree: Inlined if (call eq tree.call) && (bindings eq tree.bindings) && (expansion eq tree.expansion) => tree | ||
case _ => finalize(tree, untpd.Inlined(call, bindings, expansion)(sourceFile(tree))) | ||
} | ||
def Quote(tree: Tree)(expr: Tree, tpt: Tree)(using Context): Quote = tree match { | ||
case tree: Quote if (expr eq tree.expr) && (tpt eq tree.tpt) => tree | ||
case _ => finalize(tree, untpd.Quote(expr, tpt)(sourceFile(tree))) | ||
} | ||
def Splice(tree: Tree)(expr: Tree, tpt: Tree)(using Context): Splice = tree match { | ||
case tree: Splice if (expr eq tree.expr) && (tpt eq tree.tpt) => tree | ||
case _ => finalize(tree, untpd.Splice(expr, tpt)(sourceFile(tree))) | ||
} | ||
def SingletonTypeTree(tree: Tree)(ref: Tree)(using Context): SingletonTypeTree = tree match { | ||
case tree: SingletonTypeTree if (ref eq tree.ref) => tree | ||
case _ => finalize(tree, untpd.SingletonTypeTree(ref)(sourceFile(tree))) | ||
|
@@ -1362,6 +1395,8 @@ object Trees { | |
TypeDef(tree: Tree)(name, rhs) | ||
def Template(tree: Template)(using Context)(constr: DefDef = tree.constr, parents: List[Tree] = tree.parents, derived: List[untpd.Tree] = tree.derived, self: ValDef = tree.self, body: LazyTreeList = tree.unforcedBody): Template = | ||
Template(tree: Tree)(constr, parents, derived, self, body) | ||
def Splice(tree: Splice)(expr: Tree = tree.expr, tpt: Tree = tree.tpt)(using Context): Splice = | ||
Splice(tree: Tree)(expr, tpt) | ||
def Hole(tree: Hole)(isTerm: Boolean = tree.isTerm, idx: Int = tree.idx, args: List[Tree] = tree.args, content: Tree = tree.content, tpt: Tree = tree.tpt)(using Context): Hole = | ||
Hole(tree: Tree)(isTerm, idx, args, content, tpt) | ||
|
||
|
@@ -1494,6 +1529,10 @@ object Trees { | |
case Thicket(trees) => | ||
val trees1 = transform(trees) | ||
if (trees1 eq trees) tree else Thicket(trees1) | ||
case tree @ Quote(expr, tpt) => | ||
cpy.Quote(tree)(transform(expr), transform(tpt)) | ||
case tree @ Splice(expr, tpt) => | ||
cpy.Splice(tree)(transform(expr), transform(tpt)) | ||
case tree @ Hole(_, _, args, content, tpt) => | ||
cpy.Hole(tree)(args = transform(args), content = transform(content), tpt = transform(tpt)) | ||
case _ => | ||
|
@@ -1635,6 +1674,10 @@ object Trees { | |
this(this(x, arg), annot) | ||
case Thicket(ts) => | ||
this(x, ts) | ||
case Quote(expr, tpt) => | ||
this(this(x, expr), tpt) | ||
case Splice(expr, tpt) => | ||
this(this(x, expr), tpt) | ||
case Hole(_, _, args, content, tpt) => | ||
this(this(this(x, args), content), tpt) | ||
case _ => | ||
|
Uh oh!
There was an error while loading. Please reload this page.