Skip to content

Commit b96952b

Browse files
committed
WIP move staging before pickling
1 parent ebe73b3 commit b96952b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class Compiler {
4545

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

compiler/src/dotty/tools/dotc/transform/Staging.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Staging extends MacroTransformWithImplicits {
8383
* These will be turned into splices using `addTags` and represent types spliced
8484
* explicitly.
8585
*/
86-
val explicitTags = new mutable.LinkedHashSet[TypeRef]()
86+
val explicitTags = new mutable.LinkedHashSet[(TypeRef, Position)]()
8787

8888
/** A stack of entered symbols, to be unwound after scope exit */
8989
var enteredSyms: List[Symbol] = Nil
@@ -111,7 +111,8 @@ class Staging extends MacroTransformWithImplicits {
111111
name = UniqueName.fresh("T".toTermName).toTypeName,
112112
flags = Synthetic,
113113
info = TypeAlias(tag.tpe.select(tpnme.UNARY_~)),
114-
coord = typeRef.prefix.termSymbol.coord).asType
114+
coord = alias.pos
115+
).asType
115116

116117
ctx.typeAssigner.assignType(untpd.TypeDef(local.name, alias), local)
117118
}
@@ -126,11 +127,11 @@ class Staging extends MacroTransformWithImplicits {
126127
importedTags.clear()
127128

128129
// The tree of the tag for each tag comes from a type ref e.g., ~t
129-
val explicitTypeDefs = for (tref <- explicitTags) yield {
130-
val tag = ref(tref.prefix.termSymbol)
130+
val explicitTypeDefs = for ((tref, pos) <- explicitTags) yield {
131+
val tag = ref(tref.prefix.termSymbol).withPos(pos)
131132
mkTagSymbolAndAssignType(tref, tag)
132133
}
133-
val tagsExplicitTypeDefsPairs = explicitTags.zip(explicitTypeDefs)
134+
val tagsExplicitTypeDefsPairs = explicitTags.map(_._1).zip(explicitTypeDefs)
134135
explicitTags.clear()
135136

136137
// Maps type splices to type references of tags e.g., ~t -> some type T$1
@@ -243,7 +244,7 @@ class Staging extends MacroTransformWithImplicits {
243244
tp match {
244245
case tp: TypeRef if tp.symbol.isSplice =>
245246
if (inQuote) {
246-
explicitTags += tp
247+
explicitTags += Tuple2(tp, pos)
247248
outer.checkType(pos).foldOver(acc, tp)
248249
}
249250
else {
@@ -396,7 +397,8 @@ class Staging extends MacroTransformWithImplicits {
396397
tree.rhs match {
397398
case InlineSplice(_) =>
398399
mapOverTree(enteredSyms) // Ignore output, only check PCP
399-
cpy.DefDef(tree)(rhs = defaultValue(tree.rhs.tpe))
400+
// cpy.DefDef(tree)(rhs = defaultValue(tree.rhs.tpe))
401+
tree
400402
case _ =>
401403
ctx.error(
402404
"""Malformed macro.

0 commit comments

Comments
 (0)