summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2005-11-22 18:53:02 +0000
committerMartin Odersky <odersky@gmail.com>2005-11-22 18:53:02 +0000
commit87878dd86046ea12efe4969d3501f6c1c55f4123 (patch)
treeebd5031b3834b3d2beb30282cc084660b1da932c
parent858ca46c6efd34be774a4e09eff01f286356dc09 (diff)
downloadscala-87878dd86046ea12efe4969d3501f6c1c55f4123.tar.gz
scala-87878dd86046ea12efe4969d3501f6c1c55f4123.tar.bz2
scala-87878dd86046ea12efe4969d3501f6c1c55f4123.zip
*** empty log message ***
-rwxr-xr-xsources/scala/tools/nsc/transform/Erasure.scala18
-rwxr-xr-xsources/scala/tools/nsc/transform/Mixin.scala17
2 files changed, 23 insertions, 12 deletions
diff --git a/sources/scala/tools/nsc/transform/Erasure.scala b/sources/scala/tools/nsc/transform/Erasure.scala
index d10f3e12cc..3d651160a9 100755
--- a/sources/scala/tools/nsc/transform/Erasure.scala
+++ b/sources/scala/tools/nsc/transform/Erasure.scala
@@ -131,6 +131,15 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
/** The modifier typer which retypes with erased types. */
class Eraser(context: Context) extends Typer(context) {
+ private def evalOnce(expr: Tree, within: (() => Tree) => Tree): Tree =
+ if (treeInfo.isPureExpr(expr)) {
+ within(() => expr);
+ } else {
+ val temp = context.owner.newValue(expr.pos, context.unit.fresh.newName())
+ setFlag SYNTHETIC setInfo expr.tpe;
+ Block(List(ValDef(temp, expr)), within(() => Ident(temp) setType expr.tpe))
+ }
+
/** Box `tree' of unboxed type */
private def box(tree: Tree): Tree =
typed {
@@ -216,15 +225,6 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
(sym.name == nme.EQ || sym.name == nme.NE) && sym.info.paramTypes.head.symbol == ObjectClass ||
sym == Object_isInstanceOf || sym == Object_asInstanceOf);
- def evalOnce(expr: Tree, within: (() => Tree) => Tree): Tree =
- if (treeInfo.isPureExpr(expr)) {
- within(() => expr);
- } else {
- val temp = context.owner.newValue(expr.pos, context.unit.fresh.newName())
- setFlag SYNTHETIC setInfo expr.tpe;
- Block(List(ValDef(temp, expr)), within(() => Ident(temp) setType expr.tpe))
- }
-
/** Adapt `tree' to expected type `pt' */
private def adaptToType(tree: Tree, pt: Type): Tree = {
if (settings.debug.value && pt != WildcardType) log("adapting " + tree + ":" + tree.tpe + " to " + pt);//debug
diff --git a/sources/scala/tools/nsc/transform/Mixin.scala b/sources/scala/tools/nsc/transform/Mixin.scala
index f694732875..0d0be0de1e 100755
--- a/sources/scala/tools/nsc/transform/Mixin.scala
+++ b/sources/scala/tools/nsc/transform/Mixin.scala
@@ -260,6 +260,19 @@ abstract class Mixin extends InfoTransform {
if (sym.pos == Position.NOPOS) clazz.pos else sym.pos;
def addDefDef(sym: Symbol, rhs: List[Symbol] => Tree): unit =
addDef(position(sym), DefDef(sym, vparamss => rhs(vparamss.head)));
+ def add(stats: List[Tree], newDefs: List[Tree]) = {
+ val newSyms = newDefs map (.symbol);
+ def isNotDuplicate(tree: Tree) = tree match {
+ case DefDef(_, _, _, _, _, _) =>
+ val sym = tree.symbol;
+ !((sym hasFlag DEFERRED) &&
+ (newSyms exists (nsym => nsym.name == sym.name && (nsym.tpe matches sym.tpe))))
+ case _ =>
+ true
+ }
+ if (newDefs.isEmpty) stats
+ else stats.filter(isNotDuplicate) ::: newDefs
+ }
def completeSuperAccessor(stat: Tree) = stat match {
case DefDef(mods, name, tparams, List(vparams), tpt, EmptyTree)
if (stat.symbol hasFlag SUPERACCESSOR) =>
@@ -272,13 +285,11 @@ abstract class Mixin extends InfoTransform {
case _ =>
stat
}
- var stats1 = stats;
if (clazz hasFlag lateINTERFACE) {
for (val sym <- clazz.info.decls.toList) {
if ((sym hasFlag SYNTHETIC) && (sym hasFlag ACCESSOR))
addDefDef(sym, vparamss => EmptyTree)
}
- if (newDefs.hasNext) stats1 = stats1 ::: newDefs.toList;
} else if (!clazz.isTrait) {
for (val sym <- clazz.info.decls.toList) {
if (sym hasFlag MIXEDIN) {
@@ -304,8 +315,8 @@ abstract class Mixin extends InfoTransform {
}
}
}
- if (newDefs.hasNext) stats1 = stats1 ::: newDefs.toList;
}
+ val stats1 = add(stats, newDefs.toList);
if (clazz.isTrait) stats1 else stats1 map completeSuperAccessor;
}