summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/CleanUp.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2015-09-01 15:30:58 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2015-11-11 15:52:33 -0800
commit00fd4ac859c2b375e16f36708da01df285cd3b3c (patch)
tree7452b121235511c3f564bc997b9c78898e177d8c /src/compiler/scala/tools/nsc/transform/CleanUp.scala
parente77698fb94ff679f3bf52c23c86562156c3f7a78 (diff)
downloadscala-00fd4ac859c2b375e16f36708da01df285cd3b3c.tar.gz
scala-00fd4ac859c2b375e16f36708da01df285cd3b3c.tar.bz2
scala-00fd4ac859c2b375e16f36708da01df285cd3b3c.zip
Constructors: further clarify which defs are added & when
Move conditions and template derivation back to the call sites of `staticConstructor` (formerly `addStaticInits`).
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/CleanUp.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index 7ccbd5303c..1d98b5da31 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -49,7 +49,9 @@ abstract class CleanUp extends Statics with Transform with ast.TreeDSL {
clearStatics()
val newBody = transformTrees(body)
val templ = deriveTemplate(tree)(_ => transformTrees(newStaticMembers.toList) ::: newBody)
- try addStaticInits(templ, newStaticInits.toList, localTyper) // postprocess to include static ctors
+ try
+ if (newStaticInits.isEmpty) templ
+ else deriveTemplate(templ)(body => staticConstructor(body, localTyper, templ.pos)(newStaticInits.toList) :: body)
finally clearStatics()
}
private def mkTerm(prefix: String): TermName = unit.freshTermName(prefix)