summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/TreeInfo.scala
diff options
context:
space:
mode:
authorPaolo Giarrusso <p.giarrusso@gmail.com>2012-09-05 02:53:26 +0200
committerPaolo Giarrusso <p.giarrusso@gmail.com>2012-09-12 19:11:52 +0200
commit9568dc9d1a8e69812f4ec0b72a11a38edaa51f2a (patch)
tree847ef29de2566c2ab892bc07cf96deda4d06990e /src/reflect/scala/reflect/internal/TreeInfo.scala
parent5415272018114bb2e15036c5d6f9ae9c5af625d2 (diff)
downloadscala-9568dc9d1a8e69812f4ec0b72a11a38edaa51f2a.tar.gz
scala-9568dc9d1a8e69812f4ec0b72a11a38edaa51f2a.tar.bz2
scala-9568dc9d1a8e69812f4ec0b72a11a38edaa51f2a.zip
SI-6306 Remove incorrect eta-expansion optimization in Uncurry
Fix SI-6306 by removing the offending code. Moreover, clarify comment and add testcase. This pattern match only matches on testcases triggering SI-6306; the transformation it performs in that case is unsafe. The intended optimization is to undo eta-expansion of nullary functions, that is, transform `() => foo()` to `foo`. But that's only valid when `foo` is an instance of `Function0`, so the optimization is unsafe. Moreover, the pattern match will fail because at the end of typer that code has become `() => foo.apply()`, and `isExprSafeToInline(foo.apply)` always (correctly) fails the isExprSafeToInline test. The pattern match should thus be different - this code was dead even when it was introduced (45bcd02f6ba099277bedbf83ec2bda07435c7797), since it was not invoked either when building the compiler or when compiling function attempt2() in the included testcase. Thanks to all commenters on SI-6306 and https://github.com/scala/scala/pull/1255, in particular to Jason Zaugg for diagnosing the underlying fault and Lukas Rytz for understanding the goal of the code.
Diffstat (limited to 'src/reflect/scala/reflect/internal/TreeInfo.scala')
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index 3a930a195b..6ef4c3f660 100644
--- a/src/reflect/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -67,7 +67,7 @@ abstract class TreeInfo {
/** Is tree an expression which can be inlined without affecting program semantics?
*
- * Note that this is not called "isExprSafeToInline" since purity (lack of side-effects)
+ * Note that this is not called "isExprPure" since purity (lack of side-effects)
* is not the litmus test. References to modules and lazy vals are side-effecting,
* both because side-effecting code may be executed and because the first reference
* takes a different code path than all to follow; but they are safe to inline