diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-03-13 23:30:05 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-03-13 23:35:22 +0100 |
commit | 552b6234dbbb4ff1e971e2c0f87ecd4090dd36a5 (patch) | |
tree | 50c72971b13daedd3c2825030327fdf2abe5f1be /test | |
parent | b7b4f877326acd6a8a24ff60fa1638cc18143c45 (diff) | |
download | scala-552b6234dbbb4ff1e971e2c0f87ecd4090dd36a5.tar.gz scala-552b6234dbbb4ff1e971e2c0f87ecd4090dd36a5.tar.bz2 scala-552b6234dbbb4ff1e971e2c0f87ecd4090dd36a5.zip |
SI-7249 Reign in overzealous Function0 optimization.
The fix for SI-1247 went too far, and could result in
premature evaluation of the expression that yields the
Function0.
This commit checks that said expression is safe to inline.
If not, a wrapper `() => ....` is still required.
The optimization is still enabled in sitations like the
original test case, run/t1247.scala.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/t7249.check | 1 | ||||
-rw-r--r-- | test/files/run/t7249.scala | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/test/files/run/t7249.check b/test/files/run/t7249.check new file mode 100644 index 0000000000..7777e0a5a2 --- /dev/null +++ b/test/files/run/t7249.check @@ -0,0 +1 @@ +Yup! diff --git a/test/files/run/t7249.scala b/test/files/run/t7249.scala new file mode 100644 index 0000000000..375df5c3ad --- /dev/null +++ b/test/files/run/t7249.scala @@ -0,0 +1,7 @@ +object Test extends App { + def bnToLambda(s: => String): () => String = () => s + var x: () => String = () => sys.error("Nope") + val y = bnToLambda { x() } + x = () => "Yup!" + println(y()) +} |