diff options
author | Martin Odersky <odersky@gmail.com> | 2005-11-25 17:08:57 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2005-11-25 17:08:57 +0000 |
commit | c32643ee1bee38dd57504493e501b3345aa34188 (patch) | |
tree | 4f39251753150a699906613d5f8dd5e669b412df /sources | |
parent | 3f7799f8c66669b801852fc3848e859285ee61cb (diff) | |
download | scala-c32643ee1bee38dd57504493e501b3345aa34188.tar.gz scala-c32643ee1bee38dd57504493e501b3345aa34188.tar.bz2 scala-c32643ee1bee38dd57504493e501b3345aa34188.zip |
*** empty log message ***
Diffstat (limited to 'sources')
-rwxr-xr-x | sources/scala/tools/nsc/symtab/Types.scala | 4 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/transform/Constructors.scala | 33 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/typechecker/SyntheticMethods.scala | 2 |
3 files changed, 18 insertions, 21 deletions
diff --git a/sources/scala/tools/nsc/symtab/Types.scala b/sources/scala/tools/nsc/symtab/Types.scala index 2bb14939c0..67f31ed938 100755 --- a/sources/scala/tools/nsc/symtab/Types.scala +++ b/sources/scala/tools/nsc/symtab/Types.scala @@ -1012,6 +1012,10 @@ import Flags._; case TypeRef(pre, sym, _) => typeRef(pre, sym, args) case PolyType(tparams, restpe) => restpe.subst(tparams, args) case ErrorType => tycon + case _ => + System.out.println(tycon.getClass()); + System.out.println(tycon.$tag()); + throw new Error(); } // Hash consing -------------------------------------------------------------- diff --git a/sources/scala/tools/nsc/transform/Constructors.scala b/sources/scala/tools/nsc/transform/Constructors.scala index af4ba76eb2..54f1cc26d7 100755 --- a/sources/scala/tools/nsc/transform/Constructors.scala +++ b/sources/scala/tools/nsc/transform/Constructors.scala @@ -49,14 +49,24 @@ abstract class Constructors extends Transform { ps.head } + var thisRefSeen: boolean = false; + val intoConstructorTransformer = new Transformer { override def transform(tree: Tree): Tree = tree match { case Apply(Select(This(_), _), List()) if ((tree.symbol hasFlag PARAMACCESSOR) && tree.symbol.owner == clazz) => - gen.Ident(parameter(tree.symbol.accessed)) setPos tree.pos + thisRefSeen = true; + gen.Ident(parameter(tree.symbol.accessed)) setPos tree.pos; case Select(This(_), _) if ((tree.symbol hasFlag PARAMACCESSOR) && tree.symbol.owner == clazz) => - gen.Ident(parameter(tree.symbol)) setPos tree.pos + thisRefSeen = true; + gen.Ident(parameter(tree.symbol)) setPos tree.pos; + case This(_) => + thisRefSeen = true; + super.transform(tree) + case Super(_, _) => + thisRefSeen = true; + super.transform(tree) case _ => super.transform(tree) } @@ -94,7 +104,7 @@ abstract class Constructors extends Transform { else { if (rhs != EmptyTree) { val rhs1 = intoConstructor(stat.symbol, rhs); - (if (refersToThis(rhs1)) constrStatBuf else constrPrefixBuf) + (if (thisRefSeen) constrStatBuf else constrPrefixBuf) += mkAssign(stat.symbol, rhs1) } defBuf += copy.ValDef(stat, mods, name, tpt, EmptyTree) @@ -146,21 +156,4 @@ abstract class Constructors extends Transform { super.transform(tree) } } - - def refersToThis(tree: Tree): boolean = { - refersToThisTraverser.result = false; - refersToThisTraverser.traverse(tree); - refersToThisTraverser.result - } - - object refersToThisTraverser extends Traverser { - var result: boolean = _; - override def traverse(tree: Tree) = { - tree match { - case This(_) => result = true; - case Super(_, _) => result = true; - case _ => super.traverse(tree) - } - } - } } diff --git a/sources/scala/tools/nsc/typechecker/SyntheticMethods.scala b/sources/scala/tools/nsc/typechecker/SyntheticMethods.scala index 6715261fde..fec30d66b0 100755 --- a/sources/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/sources/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -91,7 +91,7 @@ import util.ListBuffer; val ts = new ListBuffer[Tree]; if ((clazz hasFlag CASE) && !phase.erasedTypes) { - ts += tagMethod; + ts += tagMethod; if (clazz.isModuleClass) { if (!hasImplementation(nme.toString_)) ts += moduleToStringMethod; if (clazz.isSubClass(SerializableClass)) { |