Skip to content

Commit

Permalink
SI-7011 Fix finding constructor type in captured var definitions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JamesIry committed Jan 23, 2013
1 parent 884737c commit d592216
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/transform/LambdaLift.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/files/pos/t7011.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Ydebug -Xfatal-warnings
7 changes: 7 additions & 0 deletions test/files/pos/t7011.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
object bar {
def foo {
lazy val x = 42

{()=>x}
}
}

0 comments on commit d592216

Please sign in to comment.