summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorMiguel Garcia <miguelalfredo.garcia@epfl.ch>2013-05-23 20:08:34 +0200
committerPaul Phillips <paulp@improving.org>2013-05-26 19:13:59 -0700
commit478e31a72f72e803d8716b30170dff8de0c40af9 (patch)
tree3713e14225cbb816b8dd4e47f17ca925032e329c /src/compiler
parent7a3c9b42ac376e08d17894e3e5bcf4e78dc3d3dd (diff)
downloadscala-478e31a72f72e803d8716b30170dff8de0c40af9.tar.gz
scala-478e31a72f72e803d8716b30170dff8de0c40af9.tar.bz2
scala-478e31a72f72e803d8716b30170dff8de0c40af9.zip
skipping trips to specializeTypes when not necessary in constructors
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Constructors.scala18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala
index f93d26360e..cf2b6d39a2 100644
--- a/src/compiler/scala/tools/nsc/transform/Constructors.scala
+++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala
@@ -279,7 +279,6 @@ abstract class Constructors extends Transform with ast.TreeDSL {
delayedDD.asInstanceOf[DefDef]
}
- /* @see overview at `delayedEndpointDef()` of the translation scheme for DelayedInit */
private def delayedInitClosure(delayedEndPointSym: MethodSymbol): ClassDef = {
val satelliteClass = localTyper.typed {
atPos(impl.pos) {
@@ -327,7 +326,6 @@ abstract class Constructors extends Transform with ast.TreeDSL {
satelliteClass.asInstanceOf[ClassDef]
}
- /* @see overview at `delayedEndpointDef()` of the translation scheme for DelayedInit */
private def delayedInitCall(closure: Tree) = localTyper.typedPos(impl.pos) {
gen.mkMethodCall(This(clazz), delayedInitMethod, Nil, List(New(closure.symbol.tpe, This(clazz))))
}
@@ -446,7 +444,7 @@ abstract class Constructors extends Transform with ast.TreeDSL {
// postfix = postfix.tail
// }
- if (usesSpecializedField && shouldGuard && stats.nonEmpty) {
+ if (shouldGuard && usesSpecializedField && stats.nonEmpty) {
// save them for duplication in the specialized subclass
guardedCtorStats(clazz) = stats
ctorParams(clazz) = constrInfo.constrParams
@@ -526,6 +524,15 @@ abstract class Constructors extends Transform with ast.TreeDSL {
}
}
+ /*
+ * `usesSpecializedField` makes a difference in deciding whether constructor-statements
+ * should be guarded in a `shouldGuard` class, ie in a class that's the generic super-class of
+ * one or more specialized sub-classes.
+ *
+ * Given that `usesSpecializedField` isn't read for any other purpose than the one described above,
+ * we skip setting `usesSpecializedField` in case the current class isn't `shouldGuard` to start with.
+ * That way, trips to a map in `specializeTypes` are saved.
+ */
var usesSpecializedField: Boolean = false
/*
@@ -572,9 +579,10 @@ abstract class Constructors extends Transform with ast.TreeDSL {
// references to parameter accessor field of own class become references to parameters
gen.mkAttributedIdent(parameter(tree.symbol)) setPos tree.pos
- case Select(_, _) =>
- if (possiblySpecialized(tree.symbol))
+ case Select(_, _) if shouldGuard => // reasoning behind this guard in the docu of `usesSpecializedField`
+ if (possiblySpecialized(tree.symbol)) {
usesSpecializedField = true
+ }
super.transform(tree)
case _ =>