diff options
Diffstat (limited to 'src/compiler/scala/reflect/reify')
6 files changed, 15 insertions, 44 deletions
diff --git a/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala b/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala index ce26232e5f..089f07de06 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala @@ -10,7 +10,7 @@ trait GenAnnotationInfos { // however, when reifying free and tough types, we're forced to reify annotation infos as is // why is that bad? take a look inside def reifyAnnotationInfo(ann: AnnotationInfo): Tree = { - val reifiedArgs = ann.args map { arg => + ann.args.foreach { arg => val saved1 = reifyTreeSymbols val saved2 = reifyTreeTypes diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala index d007df75e3..b2948f8161 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala @@ -106,14 +106,10 @@ trait GenTypes { private def spliceAsManifest(tpe: Type): Tree = { def isSynthetic(manifest: Tree) = manifest exists (sub => sub.symbol != null && (sub.symbol == FullManifestModule || sub.symbol.owner == FullManifestModule)) def searchForManifest(typer: analyzer.Typer): Tree = - analyzer.inferImplicit( - EmptyTree, + analyzer.inferImplicitByTypeSilent( appliedType(FullManifestClass.toTypeConstructor, List(tpe)), - reportAmbiguous = false, - isView = false, - context = typer.context, - saveAmbiguousDivergent = false, - pos = defaultErrorPosition) match { + typer.context, + defaultErrorPosition) match { case success if !success.tree.isEmpty && !isSynthetic(success.tree) => val manifestInScope = success.tree // todo. write a test for this diff --git a/src/compiler/scala/reflect/reify/codegen/GenUtils.scala b/src/compiler/scala/reflect/reify/codegen/GenUtils.scala index b5b0f93750..242e5d60b3 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenUtils.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenUtils.scala @@ -55,7 +55,7 @@ trait GenUtils { mirrorCall(TermName("" + prefix), args: _*) def scalaFactoryCall(name: TermName, args: Tree*): Tree = - call(s"scala.$name.apply", args: _*) + call(s"_root_.scala.$name.apply", args: _*) def scalaFactoryCall(name: String, args: Tree*): Tree = scalaFactoryCall(TermName(name), args: _*) diff --git a/src/compiler/scala/reflect/reify/phases/Reify.scala b/src/compiler/scala/reflect/reify/phases/Reify.scala index 143424dac5..93f6f99d81 100644 --- a/src/compiler/scala/reflect/reify/phases/Reify.scala +++ b/src/compiler/scala/reflect/reify/phases/Reify.scala @@ -1,7 +1,6 @@ package scala.reflect.reify package phases -import scala.runtime.ScalaRunTime.isAnyVal import scala.reflect.reify.codegen._ trait Reify extends GenSymbols @@ -57,4 +56,9 @@ trait Reify extends GenSymbols case _ => throw new Error("reifee %s of type %s is not supported".format(reifee, reifee.getClass)) }) + + private def isAnyVal(x: Any) = x match { + case _: Byte | _: Short | _: Char | _: Int | _: Long | _: Float | _: Double | _: Boolean | _: Unit => true + case _ => false + } } diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index 6c073c0b4c..581ce8256a 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -49,13 +49,13 @@ trait Reshape { if (discard) hk else ta case classDef @ ClassDef(mods, name, params, impl) => val Template(parents, self, body) = impl - var body1 = trimAccessors(classDef, reshapeLazyVals(body)) + var body1 = trimAccessors(classDef, body) body1 = trimSyntheticCaseClassMembers(classDef, body1) val impl1 = Template(parents, self, body1).copyAttrs(impl) ClassDef(mods, name, params, impl1).copyAttrs(classDef) case moduledef @ ModuleDef(mods, name, impl) => val Template(parents, self, body) = impl - var body1 = trimAccessors(moduledef, reshapeLazyVals(body)) + var body1 = trimAccessors(moduledef, body) body1 = trimSyntheticCaseClassMembers(moduledef, body1) val impl1 = Template(parents, self, body1).copyAttrs(impl) ModuleDef(mods, name, impl1).copyAttrs(moduledef) @@ -63,10 +63,10 @@ trait Reshape { val discardedParents = parents collect { case tt: TypeTree => tt } filter isDiscarded if (reifyDebug && discardedParents.length > 0) println("discarding parents in Template: " + discardedParents.mkString(", ")) val parents1 = parents diff discardedParents - val body1 = reshapeLazyVals(trimSyntheticCaseClassCompanions(body)) + val body1 = trimSyntheticCaseClassCompanions(body) Template(parents1, self, body1).copyAttrs(template) case block @ Block(stats, expr) => - val stats1 = reshapeLazyVals(trimSyntheticCaseClassCompanions(stats)) + val stats1 = trimSyntheticCaseClassCompanions(stats) Block(stats1, expr).copyAttrs(block) case unapply @ UnApply(Unapplied(Select(fun, nme.unapply | nme.unapplySeq)), args) => if (reifyDebug) println("unapplying unapply: " + tree) @@ -306,35 +306,6 @@ trait Reshape { stats1 } - private def reshapeLazyVals(stats: List[Tree]): List[Tree] = { - val lazyvaldefs:Map[Symbol, DefDef] = stats.collect({ case ddef: DefDef if ddef.mods.isLazy => ddef }). - map((ddef: DefDef) => ddef.symbol -> ddef).toMap - // lazy valdef and defdef are in the same block. - // only that valdef needs to have its rhs rebuilt from defdef - stats flatMap (stat => stat match { - case vdef: ValDef if vdef.symbol.isLazy => - if (reifyDebug) println(s"reconstructing original lazy value for $vdef") - val ddefSym = vdef.symbol.lazyAccessor - val vdef1 = lazyvaldefs.get(ddefSym) match { - case Some(ddef) => - toPreTyperLazyVal(ddef) - case None => - if (reifyDebug) println("couldn't find corresponding lazy val accessor") - vdef - } - if (reifyDebug) println(s"reconstructed lazy val is $vdef1") - vdef1::Nil - case ddef: DefDef if ddef.symbol.isLazy => - def hasUnitType(sym: Symbol) = (sym.tpe.typeSymbol == UnitClass) && sym.tpe.annotations.isEmpty - if (hasUnitType(ddef.symbol)) { - // since lazy values of type Unit don't have val's - // we need to create them from scratch - toPreTyperLazyVal(ddef) :: Nil - } else Nil - case _ => stat::Nil - }) - } - private def trimSyntheticCaseClassMembers(deff: Tree, stats: List[Tree]): List[Tree] = stats filterNot (memberDef => memberDef.isDef && { val isSynthetic = memberDef.symbol.isSynthetic diff --git a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala index 3b91d28360..a5c4c7e0a3 100644 --- a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala +++ b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala @@ -28,7 +28,7 @@ trait NodePrinters { var s = line substring 2 s = s.replace(nme.UNIVERSE_PREFIX.toString, "") s = s.replace(".apply", "") - s = "([^\"])scala\\.collection\\.immutable\\.".r.replaceAllIn(s, "$1") + s = "([^\"])(_root_\\.)?scala\\.collection\\.immutable\\.".r.replaceAllIn(s, "$1") s = "List\\[List\\[.*?\\].*?\\]".r.replaceAllIn(s, "List") s = "List\\[.*?\\]".r.replaceAllIn(s, "List") s = s.replace("immutable.this.Nil", "List()") |