aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2015-03-13 21:41:09 +0100
committerodersky <odersky@gmail.com>2015-03-13 21:41:09 +0100
commitc4fa153b34274dc93c9263fb77e70c98436cd7e2 (patch)
treee0976a740c39b789b044aafdba426321431bf687
parent4d0971d901d6ed9039ac5df35d95018cc3cf158d (diff)
parent3e849296a8563a561f53c92b48bd720897694b63 (diff)
downloaddotty-c4fa153b34274dc93c9263fb77e70c98436cd7e2.tar.gz
dotty-c4fa153b34274dc93c9263fb77e70c98436cd7e2.tar.bz2
dotty-c4fa153b34274dc93c9263fb77e70c98436cd7e2.zip
Merge pull request #407 from dotty-staging/fix/#400
Fix #400
-rw-r--r--src/dotty/tools/dotc/transform/ElimByName.scala3
-rw-r--r--tests/pos/i0400.scala13
2 files changed, 15 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/transform/ElimByName.scala b/src/dotty/tools/dotc/transform/ElimByName.scala
index ff774b462..5bd9c045a 100644
--- a/src/dotty/tools/dotc/transform/ElimByName.scala
+++ b/src/dotty/tools/dotc/transform/ElimByName.scala
@@ -73,7 +73,8 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform
case formalExpr: ExprType =>
val argType = arg.tpe.widen
val argFun = arg match {
- case Apply(Select(qual, nme.apply), Nil) if qual.tpe derivesFrom defn.FunctionClass(0) =>
+ case Apply(Select(qual, nme.apply), Nil)
+ if qual.tpe.derivesFrom(defn.FunctionClass(0)) && isPureExpr(qual) =>
qual
case _ =>
val meth = ctx.newSymbol(
diff --git a/tests/pos/i0400.scala b/tests/pos/i0400.scala
new file mode 100644
index 000000000..701dc88fd
--- /dev/null
+++ b/tests/pos/i0400.scala
@@ -0,0 +1,13 @@
+object Test {
+ def foo: Unit = {
+ def a = () => ""
+ bar({???; a}.apply())
+ }
+ def bar(a: => Any): Unit = {
+ baz(a)
+ }
+ def baz(a: => Any): Unit = ()
+ def main(args: Array[String]): Unit = {
+ foo
+ }
+}