diff options
-rw-r--r-- | src/dotty/tools/dotc/transform/ElimByName.scala | 3 | ||||
-rw-r--r-- | tests/pos/i0400.scala | 13 |
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 + } +} |