From 66577fa6ec07de9769150019deeafb25a1e5422a Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Fri, 22 Nov 2013 22:13:44 +0100 Subject: SI-8001 spurious "pure expression does nothing" warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `isPureExprForWarningPurposes` doesn’t warn on `()`, but `(): Unit` leaves it confused. This patch fixes the problem. The fix is important in the context of the recent split between blackbox and whitebox macros. Macro engines wrap expansions of blackbox macros in type ascriptions, so a macro that expands into `()` would actually produce `(): Unit`, which would trigger a spurious warning. Thanks @milessabin for spotting this problem! --- src/reflect/scala/reflect/internal/TreeInfo.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index 8982fd4246..48db8f7bf7 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -199,7 +199,8 @@ abstract class TreeInfo { * don't reuse it for important matters like inlining * decisions. */ - def isPureExprForWarningPurposes(tree: Tree) = tree match { + def isPureExprForWarningPurposes(tree: Tree): Boolean = tree match { + case Typed(expr, _) => isPureExprForWarningPurposes(expr) case EmptyTree | Literal(Constant(())) => false case _ => def isWarnableRefTree = tree match { -- cgit v1.2.3