diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-11-25 14:40:20 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-11-25 14:40:20 -0800 |
commit | d19954eb94afb27ca90b3bbcfb9eecec5e85428a (patch) | |
tree | b5b1f8e77afecdc7f4a5f7b6ea8c9751a552bb70 | |
parent | 554f1bbf91084cb501584971f2c90809c819c0a5 (diff) | |
parent | 66577fa6ec07de9769150019deeafb25a1e5422a (diff) | |
download | scala-d19954eb94afb27ca90b3bbcfb9eecec5e85428a.tar.gz scala-d19954eb94afb27ca90b3bbcfb9eecec5e85428a.tar.bz2 scala-d19954eb94afb27ca90b3bbcfb9eecec5e85428a.zip |
Merge pull request #3183 from xeno-by/topic/pure-expression-does-nothing
SI-8001 spurious "pure expression does nothing" warning
-rw-r--r-- | src/reflect/scala/reflect/internal/TreeInfo.scala | 3 | ||||
-rw-r--r-- | test/files/pos/t8001.check | 0 | ||||
-rw-r--r-- | test/files/pos/t8001.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t8001/Macros_1.scala | 10 | ||||
-rw-r--r-- | test/files/pos/t8001/Test_2.scala | 4 | ||||
-rw-r--r-- | test/files/run/macro-system-properties.check | 6 |
6 files changed, 17 insertions, 7 deletions
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index a933a5d189..8fdf4dc27a 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 { diff --git a/test/files/pos/t8001.check b/test/files/pos/t8001.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/pos/t8001.check diff --git a/test/files/pos/t8001.flags b/test/files/pos/t8001.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/t8001.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t8001/Macros_1.scala b/test/files/pos/t8001/Macros_1.scala new file mode 100644 index 0000000000..1f8dab51c1 --- /dev/null +++ b/test/files/pos/t8001/Macros_1.scala @@ -0,0 +1,10 @@ +import scala.language.experimental.macros +import scala.reflect.macros.BlackboxContext + +object Macros { + def foo = macro impl + def impl(c: BlackboxContext) = { + import c.universe._ + q"()" + } +}
\ No newline at end of file diff --git a/test/files/pos/t8001/Test_2.scala b/test/files/pos/t8001/Test_2.scala new file mode 100644 index 0000000000..6d72d96070 --- /dev/null +++ b/test/files/pos/t8001/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + Macros.foo + (): Unit +}
\ No newline at end of file diff --git a/test/files/run/macro-system-properties.check b/test/files/run/macro-system-properties.check index b102d319ec..ea4c5a664a 100644 --- a/test/files/run/macro-system-properties.check +++ b/test/files/run/macro-system-properties.check @@ -14,15 +14,9 @@ scala> object GrabContext { defined object GrabContext scala> object Test { class C(implicit a: Any) { GrabContext.grab } } -<console>:12: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses - object Test { class C(implicit a: Any) { GrabContext.grab } } - ^ defined object Test scala> object Test { class C(implicit a: Any) { GrabContext.grab } } -<console>:12: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses - object Test { class C(implicit a: Any) { GrabContext.grab } } - ^ defined object Test scala> |