diff options
author | Miguel Garcia <miguelalfredo.garcia@epfl.ch> | 2013-05-22 20:19:54 +0200 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-05-26 19:13:57 -0700 |
commit | ac7bbc8f73f9be02baf5feeeef0fcfe5f386156c (patch) | |
tree | b5bbb5599e92c3be36e92630868f7682d91a48ab | |
parent | b7add1517bc888ac55c2e2e34d456a3fd17bbe0d (diff) | |
download | scala-ac7bbc8f73f9be02baf5feeeef0fcfe5f386156c.tar.gz scala-ac7bbc8f73f9be02baf5feeeef0fcfe5f386156c.tar.bz2 scala-ac7bbc8f73f9be02baf5feeeef0fcfe5f386156c.zip |
handling AnyVal special case early on to simplify logic afterwards
This way the contract of `transformClassTemplate()` can focus on
non-AnyVal cases, which are more regular from the perspective of
transforming their templates in the constructors phase.
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Constructors.scala | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 77c2d13b78..7c7c6609c5 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -44,13 +44,12 @@ abstract class Constructors extends Transform with ast.TreeDSL { ) // decompose primary constructor into the three entities above. val constrInfo: ConstrInfo = { - stats find (_.symbol.isPrimaryConstructor) match { + val ddef = (stats find (_.symbol.isPrimaryConstructor)) + ddef match { case Some(ddef @ DefDef(_, _, _, List(vparams), _, rhs @ Block(_, _))) => ConstrInfo(ddef, vparams map (_.symbol), rhs) case x => - // AnyVal constructor is OK - assert(clazz eq AnyValClass, "no constructor in template: impl = " + impl) - return impl + abort("no constructor in template: impl = " + impl) } } import constrInfo._ @@ -594,8 +593,13 @@ abstract class Constructors extends Transform with ast.TreeDSL { override def transform(tree: Tree): Tree = { tree match { case cd : ClassDef if !cd.symbol.isInterface && !isPrimitiveValueClass(cd.symbol) => - checkUninitializedReads(cd) - deriveClassDef(cd)(transformClassTemplate) + if(cd.symbol eq AnyValClass) { + cd + } + else { + checkUninitializedReads(cd) + deriveClassDef(cd)(transformClassTemplate) + } case _ => super.transform(tree) } |