diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2011-12-04 20:27:06 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2011-12-04 20:46:58 +0100 |
commit | 9393efc68a2c057a9b6e7d1c148355024d46a8aa (patch) | |
tree | 02a4321829e1bff80b3a9c714437170e1717f0a5 /src/compiler | |
parent | 3e9e4ecf360e6eda5c26f798abfcb9bb882cf772 (diff) | |
download | scala-9393efc68a2c057a9b6e7d1c148355024d46a8aa.tar.gz scala-9393efc68a2c057a9b6e7d1c148355024d46a8aa.tar.bz2 scala-9393efc68a2c057a9b6e7d1c148355024d46a8aa.zip |
Reification of classes now produces trees that can be compiled and run.
Multiple minor fixes to Martin's implementation of reflection infrastructure.
Dominating theme is allowing for the fact that compilation via reflection
involves numerous exports/imports between various reflection universes.
Fixes SI-5230. Review by @odersky.
Diffstat (limited to 'src/compiler')
4 files changed, 16 insertions, 2 deletions
diff --git a/src/compiler/scala/reflect/internal/Importers.scala b/src/compiler/scala/reflect/internal/Importers.scala index 6d672d9263..60b353a7c4 100644 --- a/src/compiler/scala/reflect/internal/Importers.scala +++ b/src/compiler/scala/reflect/internal/Importers.scala @@ -231,6 +231,8 @@ trait Importers { self: SymbolTable => new PackageDef(importRefTree(pid), stats map importTree) case from.ModuleDef(mods, name, impl) => new ModuleDef(importModifiers(mods), importName(name).toTermName, importTemplate(impl)) + case from.emptyValDef => + emptyValDef case from.ValDef(mods, name, tpt, rhs) => new ValDef(importModifiers(mods), importName(name).toTermName, importTree(tpt), importTree(rhs)) case from.DefDef(mods, name, tparams, vparamss, tpt, rhs) => diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 320fb949ff..265261f594 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -4174,8 +4174,16 @@ A type's typeSymbol should never be inspected directly. private def adaptToNewRun(pre: Type, sym: Symbol): Symbol = { if (phase.flatClasses) { sym + } else if (sym == definitions.RootClass) { + definitions.RootClass + } else if (sym == definitions.RootPackage) { + definitions.RootPackage } else if (sym.isModuleClass) { - adaptToNewRun(pre, sym.sourceModule).moduleClass + val sourceModule1 = adaptToNewRun(pre, sym.sourceModule) + val result = sourceModule1.moduleClass + val msg = "sym = %s, sourceModule = %s, sourceModule.moduleClass = %s => sourceModule1 = %s, sourceModule1.moduleClass = %s" + assert(result != NoSymbol, msg.format(sym, sym.sourceModule, sym.sourceModule.moduleClass, sourceModule1, sourceModule1.moduleClass)) + result } else if ((pre eq NoPrefix) || (pre eq NoType) || sym.isPackageClass) { sym } else { diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 9668debbbb..85849cfad4 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -257,6 +257,10 @@ trait Trees extends reflect.internal.Trees { self: Global => case _: DefTree | Function(_, _) | Template(_, _, _) => resetDef(tree) tree.tpe = null + tree match { + case tree: DefDef => tree.tpt.tpe = null + case _ => () + } case tpt: TypeTree => if (tpt.wasEmpty) tree.tpe = null case This(_) if tree.symbol != null && tree.symbol.isPackageClass => diff --git a/src/compiler/scala/tools/nsc/transform/LiftCode.scala b/src/compiler/scala/tools/nsc/transform/LiftCode.scala index 7a64fc9b5e..68a53e57a1 100644 --- a/src/compiler/scala/tools/nsc/transform/LiftCode.scala +++ b/src/compiler/scala/tools/nsc/transform/LiftCode.scala @@ -475,7 +475,7 @@ abstract class LiftCode extends Transform with TypingTransformers { case tt: TypeTree if (tt.tpe != null) => if (!(boundSyms exists (tt.tpe contains _))) mirrorCall("TypeTree", reifyType(tt.tpe)) else if (tt.original != null) reify(tt.original) - else TypeTree() + else mirrorCall("TypeTree") case global.emptyValDef => mirrorSelect("emptyValDef") case _ => |