From d592216a12d8bd145f6a670554e9217944c2b169 Mon Sep 17 00:00:00 2001 From: James Iry Date: Wed, 23 Jan 2013 01:30:10 -0800 Subject: SI-7011 Fix finding constructor type in captured var definitions If a captured var was initialized with an empty tree then finding the type of the empty tree was being handled improperly. The fix is to look for primary constructors on the tree's type symbol rather than the tree's symbol. A test is included. In order to make the problem more testable the debug logging of the issue is changed to a debug warn. --- src/compiler/scala/tools/nsc/transform/LambdaLift.scala | 4 ++-- test/files/pos/t7011.flags | 1 + test/files/pos/t7011.scala | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 test/files/pos/t7011.flags create mode 100644 test/files/pos/t7011.scala diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index 4a23e65ad2..c59d0b5b27 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -430,10 +430,10 @@ abstract class LambdaLift extends InfoTransform { /* Creating a constructor argument if one isn't present. */ val constructorArg = rhs match { case EmptyTree => - sym.primaryConstructor.info.paramTypes match { + sym.tpe.typeSymbol.primaryConstructor.info.paramTypes match { case List(tp) => gen.mkZero(tp) case _ => - log("Couldn't determine how to properly construct " + sym) + debugwarn("Couldn't determine how to properly construct " + sym) rhs } case arg => arg diff --git a/test/files/pos/t7011.flags b/test/files/pos/t7011.flags new file mode 100644 index 0000000000..a4c161553e --- /dev/null +++ b/test/files/pos/t7011.flags @@ -0,0 +1 @@ +-Ydebug -Xfatal-warnings \ No newline at end of file diff --git a/test/files/pos/t7011.scala b/test/files/pos/t7011.scala new file mode 100644 index 0000000000..539f662bc0 --- /dev/null +++ b/test/files/pos/t7011.scala @@ -0,0 +1,7 @@ +object bar { + def foo { + lazy val x = 42 + + {()=>x} + } +} \ No newline at end of file -- cgit v1.2.3