summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/reify/codegen/Trees.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-04-14 21:11:37 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-04-14 21:11:37 +0200
commit5e4c47f33b8e25feb59ab4599231b1b8d3150de8 (patch)
treeff2ded10d14c5a6e859ac216e60244029a17a505 /src/compiler/scala/reflect/reify/codegen/Trees.scala
parent3a2901da406f2478b5634b0636e56de9c4cd676d (diff)
downloadscala-5e4c47f33b8e25feb59ab4599231b1b8d3150de8.tar.gz
scala-5e4c47f33b8e25feb59ab4599231b1b8d3150de8.tar.bz2
scala-5e4c47f33b8e25feb59ab4599231b1b8d3150de8.zip
implements reification of tough types
Diffstat (limited to 'src/compiler/scala/reflect/reify/codegen/Trees.scala')
-rw-r--r--src/compiler/scala/reflect/reify/codegen/Trees.scala20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/compiler/scala/reflect/reify/codegen/Trees.scala b/src/compiler/scala/reflect/reify/codegen/Trees.scala
index 22f42aea49..5ad53c0009 100644
--- a/src/compiler/scala/reflect/reify/codegen/Trees.scala
+++ b/src/compiler/scala/reflect/reify/codegen/Trees.scala
@@ -8,6 +8,11 @@ trait Trees {
import definitions._
import treeInfo._
+ // unfortunately, these are necessary to reify AnnotatedTypes
+ // I'd gladly got rid of them, but I don't fancy making a metaprogramming API that doesn't work with annotated types
+ var reifyTreeSymbols = false
+ var reifyTreeTypes = false
+
/**
* Reify a tree.
* For internal use only, use ``reified'' instead.
@@ -59,6 +64,17 @@ trait Trees {
reifyProduct(tree)
}
+ // usually we don't reify symbols/types, because they can be re-inferred during subsequent reflective compilation
+ // however, reification of AnnotatedTypes is special. see ``reifyType'' to find out why.
+ if (reifyTreeSymbols && tree.hasSymbol) {
+ if (reifyDebug) println("reifying symbol %s for tree %s".format(tree.symbol, tree))
+ rtree = Apply(Select(rtree, nme.setSymbol), List(reifySymRef(tree.symbol)))
+ }
+ if (reifyTreeTypes && tree.tpe != null) {
+ if (reifyDebug) println("reifying type %s for tree %s".format(tree.tpe, tree))
+ rtree = Apply(Select(rtree, nme.setType), List(reifyType(tree.tpe)))
+ }
+
rtree
}
@@ -82,7 +98,7 @@ trait Trees {
case InlinedTreeSplice(_, inlinedSymbolTable, tree, _) =>
if (reifyDebug) println("inlining the splicee")
// all free vars local to the enclosing reifee should've already been inlined by ``Metalevels''
- inlinedSymbolTable foreach { case freedef @ FreeDef(_, _, binding, _) => assert(!binding.symbol.isLocalToReifee, freedef) }
+ inlinedSymbolTable collect { case freedef @ FreeDef(_, _, binding, _) if binding.symbol.isLocalToReifee => assert(false, freedef) }
symbolTable ++= inlinedSymbolTable
tree
case tree =>
@@ -152,7 +168,7 @@ trait Trees {
val tpe = tpe0.dealias
if (reifyDebug) println("reifying bound type %s (underlying type is %s, dealiased is %s)".format(sym0, tpe0, tpe))
- if (eligibleForSplicing(tpe)) {
+ if (tpe.isSpliceable) {
val spliced = spliceType(tpe)
if (spliced == EmptyTree) {
if (reifyDebug) println("splicing failed: reify as is")