summaryrefslogtreecommitdiff
path: root/test/files/pos/t8001
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-11-22 22:13:44 +0100
committerEugene Burmako <xeno.by@gmail.com>2013-11-23 14:39:11 +0100
commit66577fa6ec07de9769150019deeafb25a1e5422a (patch)
treefe6228f2a528c47c7e08d35ff3caa201410a00f3 /test/files/pos/t8001
parent42657a6918ef7d6fd3f36838739ec8a3b64744a3 (diff)
downloadscala-66577fa6ec07de9769150019deeafb25a1e5422a.tar.gz
scala-66577fa6ec07de9769150019deeafb25a1e5422a.tar.bz2
scala-66577fa6ec07de9769150019deeafb25a1e5422a.zip
SI-8001 spurious "pure expression does nothing" warning
`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!
Diffstat (limited to 'test/files/pos/t8001')
-rw-r--r--test/files/pos/t8001/Macros_1.scala10
-rw-r--r--test/files/pos/t8001/Test_2.scala4
2 files changed, 14 insertions, 0 deletions
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