Skip to content

Commit 3350891

Browse files
committed
WIP
1 parent 08a78f2 commit 3350891

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,31 +93,27 @@ class Staging extends MacroTransformWithImplicits {
9393
if (ctx.compilationUnit.needsStaging) super.run
9494

9595
protected def newTransformer(implicit ctx: Context): Transformer =
96-
new Reifier(inQuote = false, null, 0, new LevelInfo, ctx)
96+
new Reifier(0, new LevelInfo)
9797

9898
private class LevelInfo {
9999
/** A map from locally defined symbols to the staging levels of their definitions */
100100
val levelOf = new mutable.HashMap[Symbol, Int]
101101
}
102102

103103
/** The main transformer class
104-
* @param inQuote we are within a `'(...)` context that is not shadowed by a nested `~(...)`
105-
* @param outer the next outer reifier, null is this is the topmost transformer
106104
* @param level the current level, where quotes add one and splices subtract one level.
107105
* The initial level is 0, a level `l` where `l > 0` implies code has been quoted `l` times
108106
* and `l == -1` is code inside a top level splice (in an inline method).
109107
* @param levels a stacked map from symbols to the levels in which they were defined
110-
* @param embedded a list of embedded quotes (if `inSplice = true`) or splices (if `inQuote = true`
111-
* @param rctx the contex in the destination lifted lambda
112108
*/
113-
private class Reifier(inQuote: Boolean, val outer: Reifier, val level: Int, levels: LevelInfo, val rctx: Context)
109+
private class Reifier(val level: Int, levels: LevelInfo)
114110
extends ImplicitsTransformer {
115111
import levels._
116112
assert(level >= -1)
117113

118114
/** A nested reifier for a quote (if `isQuote = true`) or a splice (if not) */
119115
def nested(isQuote: Boolean)(implicit ctx: Context): Reifier = {
120-
new Reifier(isQuote, this, if (isQuote) level + 1 else level - 1, levels, ctx)
116+
new Reifier(if (isQuote) level + 1 else level - 1, levels)
121117
}
122118

123119
/** A stack of entered symbols, to be unwound after scope exit */
@@ -212,14 +208,9 @@ class Staging extends MacroTransformWithImplicits {
212208
def apply(tp: Type): Type = reporting.trace(i"check type level $tp at $level") {
213209
tp match {
214210
case tp: TypeRef if tp.symbol.isSplice =>
215-
if (inQuote) {
216-
// TODO add level to checkType TypeMap and avoid accessing the outer one?
217-
outer.checkType(pos).mapOver(tp)
218-
}
219-
else {
220-
if (tp.isTerm) ctx.error(i"splice outside quotes", pos)
211+
if (tp.isTerm)
212+
ctx.error(i"splice outside quotes", pos)
221213
tp
222-
}
223214
case tp: NamedType =>
224215
check(tp.symbol, tp, tp.symbol.sourcePos) match {
225216
case Some(tpRef) => tpRef.tpe

0 commit comments

Comments
 (0)