diff options
author | Miguel Garcia <miguelalfredo.garcia@epfl.ch> | 2013-07-08 15:19:05 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-08-08 12:09:48 -0700 |
commit | 0512c382e352edafb3871caf04b989f0b21ad093 (patch) | |
tree | 5d62bb7da7d22bd7563188ebbcc230c830114e23 /src/compiler/scala/tools/nsc/transform/Constructors.scala | |
parent | 23925fc2840e1805769afd41713aa15e835fce3f (diff) | |
download | scala-0512c382e352edafb3871caf04b989f0b21ad093.tar.gz scala-0512c382e352edafb3871caf04b989f0b21ad093.tar.bz2 scala-0512c382e352edafb3871caf04b989f0b21ad093.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.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/Constructors.scala')
-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 f05b78f972..43414f2777 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -43,13 +43,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._ @@ -597,8 +596,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) } |