Skip to content

Extract quote reification from Staging #5701

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

Closed
wants to merge 14 commits into from
Closed
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ class Compiler {

/** Phases dealing with TASTY tree pickling and unpickling */
protected def picklerPhases: List[List[Phase]] =
List(new Staging) :: // Check quotation levels (while healing types) and expand macros
List(new Pickler) :: // Generate TASTY info
List(new Staging) :: // Expand macros and turn quoted trees into explicit run-time data structures
List(new ReifyQuotes) :: // Turn quoted trees into explicit run-time data structures
Nil

/** Phases dealing with the transformation from pickled trees to backend trees */
Expand Down
7 changes: 6 additions & 1 deletion compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class TreeTypeMap(
assert(!to.exists(substFrom contains _))
assert(!from.exists(newOwners contains _))
assert(!to.exists(oldOwners contains _))
new TreeTypeMap(
newTreeTypeMap(
typeMap,
treeMap,
from ++ oldOwners,
Expand All @@ -171,6 +171,11 @@ class TreeTypeMap(
to ++ substTo)
}

protected def newTreeTypeMap(typeMap: Type => Type, treeMap: tpd.Tree => tpd.Tree,
oldOwners: List[Symbol], newOwners: List[Symbol], substFrom: List[Symbol], substTo: List[Symbol]) = {
new TreeTypeMap(typeMap, treeMap, oldOwners, newOwners, substFrom, substTo)
}

/** Apply `typeMap` and `ownerMap` to given symbols `syms`
* and return a treemap that contains the substitution
* between original and mapped symbols.
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/quoted/TreeCleaner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TreeCleaner extends tpd.TreeMap {

override def transform(tree: Tree)(implicit ctx: Context): Tree = {
val tree0 = tree match {
case TypeDef(_, TypeBoundsTree(lo, hi)) if lo == hi =>
case TypeDef(_, TypeBoundsTree(lo, hi)) if lo.tpe =:= hi.tpe =>
aliasesSyms = tree.symbol :: aliasesSyms
aliasesTypes = lo.tpe :: aliasesTypes
aliases(tree.symbol) = ref(lo.tpe.typeSymbol)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
tpd.Return(expr, ctx.owner)

def copy(original: Tree)(expr: Term)(implicit ctx: Context): Return =
tpd.cpy.Return(original)(expr, tpd.EmptyTree)
tpd.cpy.Return(original)(expr, tpd.ref(ctx.owner))

def unapply(x: Term)(implicit ctx: Context): Option[Term] = x match {
case x: tpd.Return => Some(x.expr)
Expand Down
Loading