Skip to content

Commit

Permalink
improved naming of variables in constructors phase
Browse files Browse the repository at this point in the history
  • Loading branch information
magarciaEPFL committed Apr 25, 2013
1 parent b4fbb7b commit fc8387f
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/compiler/scala/tools/nsc/transform/Constructors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,6 @@ abstract class Constructors extends Transform with ast.TreeDSL {
} else stats
}

// def isInitDef(stat: Tree) = stat match {
// case dd: DefDef => dd.symbol == delayedInitMethod
// case _ => false
// }


/*
* Translation scheme for DelayedInit
* ----------------------------------
Expand Down Expand Up @@ -486,7 +480,7 @@ abstract class Constructors extends Transform with ast.TreeDSL {

/* @see overview at `delayedEndpointDef()` of the translation scheme for DelayedInit */
def delayedInitClosure(delayedEndPointSym: MethodSymbol): ClassDef = {
val dicl = localTyper.typed {
val satelliteClass = localTyper.typed {
atPos(impl.pos) {
val closureClass = clazz.newClass(nme.delayedInitArg.toTypeName, impl.pos, SYNTHETIC | FINAL)
val closureParents = List(AbstractFunctionClass(0).tpe)
Expand Down Expand Up @@ -529,7 +523,7 @@ abstract class Constructors extends Transform with ast.TreeDSL {
}
}

dicl.asInstanceOf[ClassDef]
satelliteClass.asInstanceOf[ClassDef]
}

/* @see overview at `delayedEndpointDef()` of the translation scheme for DelayedInit */
Expand All @@ -555,19 +549,18 @@ abstract class Constructors extends Transform with ast.TreeDSL {
* See test case files/run/bug4680.scala, the output of which is wrong in many
* particulars.
*/
val needsDelayedInit =
isDelayedInitSubclass /*&& !(defBuf exists isInitDef)*/ && remainingConstrStats.nonEmpty
val needsDelayedInit = (isDelayedInitSubclass && remainingConstrStats.nonEmpty)

if (needsDelayedInit) {
val dlydEpDef: DefDef = delayedEndpointDef(remainingConstrStats)
defBuf += dlydEpDef
val dicl = {
val delayedHook: DefDef = delayedEndpointDef(remainingConstrStats)
defBuf += delayedHook
val hookCallerClass = {
// transform to make the closure-class' default constructor assign the the outer instance to its param-accessor field.
val diclx = new ConstructorTransformer(unit)
diclx transform delayedInitClosure(dlydEpDef.symbol.asInstanceOf[MethodSymbol])
val drillDown = new ConstructorTransformer(unit)
drillDown transform delayedInitClosure(delayedHook.symbol.asInstanceOf[MethodSymbol])
}
defBuf += dicl
remainingConstrStats = delayedInitCall(dicl) :: Nil
defBuf += hookCallerClass
remainingConstrStats = delayedInitCall(hookCallerClass) :: Nil
}

// Assemble final constructor
Expand Down

0 comments on commit fc8387f

Please sign in to comment.