summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/reify/phases/Calculate.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/reflect/reify/phases/Calculate.scala')
-rw-r--r--src/compiler/scala/reflect/reify/phases/Calculate.scala17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/compiler/scala/reflect/reify/phases/Calculate.scala b/src/compiler/scala/reflect/reify/phases/Calculate.scala
index 93ef46472e..41cf6c066a 100644
--- a/src/compiler/scala/reflect/reify/phases/Calculate.scala
+++ b/src/compiler/scala/reflect/reify/phases/Calculate.scala
@@ -4,25 +4,26 @@ package phases
trait Calculate {
self: Reifier =>
- import mirror._
+ import global._
import definitions._
- import treeInfo._
- implicit class RichSymbol(sym: Symbol) {
- def metalevel: Int = { assert(sym != NoSymbol); localSymbols.getOrElse(sym, 0) }
+ implicit class RichCalculateSymbol(sym: Symbol) {
+ def metalevel: Int = { assert(sym != null && sym != NoSymbol); localSymbols.getOrElse(sym, 0) }
def isLocalToReifee = (localSymbols contains sym) // [Eugene] how do I account for local skolems?
}
- implicit class RichType(tpe: Type) {
+ implicit class RichCalculateType(tpe: Type) {
def isLocalToReifee = tpe != null && (tpe exists (tp => (localSymbols contains tp.typeSymbol) || (localSymbols contains tp.termSymbol)))
}
- private var localSymbols = collection.mutable.Map[Symbol, Int]() // set of all symbols that are local to the tree to be reified
+ private def localSymbols: Map[Symbol, Int] = state.localSymbols // set of all symbols that are local to the tree to be reified
+ private def localSymbols_=(value: Map[Symbol, Int]): Unit = state.localSymbols = value
private def registerLocalSymbol(sym: Symbol, metalevel: Int): Unit =
if (sym != null && sym != NoSymbol) {
if (localSymbols contains sym)
assert(localSymbols(sym) == metalevel, "metalevel mismatch: expected %s, actual %s".format(localSymbols(sym), metalevel))
- localSymbols(sym) = metalevel
+ else
+ localSymbols += (sym -> metalevel)
}
/**
@@ -38,7 +39,7 @@ trait Calculate {
try super.traverse(tree)
finally currMetalevel += 1
case tree if tree.isDef =>
- if (reifyDebug) println("boundSym: %s of type %s".format(tree.symbol, (tree.productIterator.toList collect { case tt: TypeTree => tt } headOption).getOrElse(TypeTree(tree.tpe))))
+ if (reifyDebug) println("boundSym: %s of type %s".format(tree.symbol, (tree.productIterator.toList collect { case tt: TypeTree => tt }).headOption.getOrElse(TypeTree(tree.tpe))))
registerLocalSymbol(tree.symbol, currMetalevel)
bindRelatedSymbol(tree.symbol.sourceModule, "sourceModule")