Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

SI-7011 Fix finding constructor type in captured var definitions #1956

Merged
merged 1 commit into from

4 participants

@JamesIry

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.

review @retronym

@JamesIry JamesIry 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.
d592216
@scala-jenkins

Started jenkins job JenkinsJob(pr-scala-testsuite-linux-opt) at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2202/

@scala-jenkins

Started jenkins job JenkinsJob(pr-rangepos) at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1483/

@adriaanm
Owner

jenkins job pr-scala-testsuite-linux-opt: successful -- manually verified

@adriaanm
Owner

jenkins job pr-rangepos: successful -- manually verified

@retronym
Owner

lgtm

@JamesIry JamesIry merged commit 2fa859e into scala:2.10.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 23, 2013
  1. @JamesIry

    SI-7011 Fix finding constructor type in captured var definitions

    JamesIry authored
    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.
This page is out of date. Refresh to see the latest.
View
4 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
View
1  test/files/pos/t7011.flags
@@ -0,0 +1 @@
+-Ydebug -Xfatal-warnings
View
7 test/files/pos/t7011.scala
@@ -0,0 +1,7 @@
+object bar {
+ def foo {
+ lazy val x = 42
+
+ {()=>x}
+ }
+}
Something went wrong with that request. Please try again.