From 3b8fee9184ebe1be9dfea690e180918b176726a3 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Wed, 11 Aug 2010 12:32:07 +0000 Subject: Correct fix for see #3726. --- src/compiler/scala/tools/nsc/ast/TreeInfo.scala | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala index 546e62f85a..394e9709a1 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala @@ -85,6 +85,13 @@ abstract class TreeInfo { tree.symbol.isStable && isPureExpr(qual) case TypeApply(fn, _) => isPureExpr(fn) + case Apply(fn, List()) => + /* Note: After uncurry, field accesses are represented as Apply(getter, Nil), + * so an Apply can also be pure. + * However, before typing, applications of nullary functional values are also + * Apply(function, Nil) trees. To prevent them from being treated as pure, + * we check that the callee is a method. */ + fn.symbol.isMethod && isPureExpr(fn) case Typed(expr, _) => isPureExpr(expr) case Block(stats, expr) => -- cgit v1.2.3