summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-10-25 21:15:34 +0000
committerPaul Phillips <paulp@improving.org>2010-10-25 21:15:34 +0000
commit7f365342d9875ffc4105af26faa260f81a270246 (patch)
tree4accac53322e84a6bfc9b530bcd2745283124f75 /src/compiler/scala/tools/nsc/transform/LambdaLift.scala
parent5c322510b185e7ee50ec6f75057369c427b9724b (diff)
downloadscala-7f365342d9875ffc4105af26faa260f81a270246.tar.gz
scala-7f365342d9875ffc4105af26faa260f81a270246.tar.bz2
scala-7f365342d9875ffc4105af26faa260f81a270246.zip
The tree checkers revealed that Volatile*Refs w...
The tree checkers revealed that Volatile*Refs were being constructed without being given a constructor argument. Added a mkZero to treegen for creating zero trees of any type, and used it to construct those refs. Review by moors.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/LambdaLift.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/LambdaLift.scala19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
index 184065a7ed..e3f1427360 100644
--- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
+++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
@@ -405,13 +405,20 @@ abstract class LambdaLift extends InfoTransform {
case ValDef(mods, name, tpt, rhs) =>
if (sym.isCapturedVariable) {
val tpt1 = TypeTree(sym.tpe) setPos tpt.pos
- val rhs1 =
- atPos(rhs.pos) {
- typer typed {
- Apply(Select(New(TypeTree(sym.tpe)), nme.CONSTRUCTOR), List(rhs))
+ /* Creating a constructor argument if one isn't present. */
+ val constructorArg = rhs match {
+ case EmptyTree =>
+ sym.primaryConstructor.info.paramTypes match {
+ case List(tp) => gen.mkZero(tp)
+ case _ =>
+ log("Couldn't determine how to properly construct " + sym)
+ rhs
}
- }
- treeCopy.ValDef(tree, mods, name, tpt1, rhs1)
+ case arg => arg
+ }
+ treeCopy.ValDef(tree, mods, name, tpt1, typer.typedPos(rhs.pos) {
+ Apply(Select(New(TypeTree(sym.tpe)), nme.CONSTRUCTOR), List(constructorArg))
+ })
} else tree
case Return(Block(stats, value)) =>
Block(stats, treeCopy.Return(tree, value)) setType tree.tpe setPos tree.pos