summaryrefslogtreecommitdiff
path: root/test/files/neg/macro-blackbox-structural
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-10-02 17:21:27 +0200
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-11-12 18:40:01 -0800
commita2b523a39b4e56eb9ab5d9a5639f5b59d425e354 (patch)
tree8d91dd18059b1166d9e7d3ee6a1ab22166d0ae7b /test/files/neg/macro-blackbox-structural
parentce37ae45e22463a3f1a2d659d6699f2977b26c6b (diff)
downloadscala-a2b523a39b4e56eb9ab5d9a5639f5b59d425e354.tar.gz
scala-a2b523a39b4e56eb9ab5d9a5639f5b59d425e354.tar.bz2
scala-a2b523a39b4e56eb9ab5d9a5639f5b59d425e354.zip
blackbox restriction #1: can't refine the official return type
When an application of a blackbox macro expands into a tree `x`, the expansion is wrapped into a type ascription `(x: T)`, where `T` is the declared return type of the blackbox macro with type arguments and path dependencies applied in consistency with the particular macro application being expanded. This invalidates blackbox macros as an implementation vehicle of type providers.
Diffstat (limited to 'test/files/neg/macro-blackbox-structural')
-rw-r--r--test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala15
-rw-r--r--test/files/neg/macro-blackbox-structural/Test_2.scala5
2 files changed, 20 insertions, 0 deletions
diff --git a/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala b/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala
new file mode 100644
index 0000000000..08f1c21e89
--- /dev/null
+++ b/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala
@@ -0,0 +1,15 @@
+import scala.language.experimental.macros
+
+object Macros {
+ def impl(c: scala.reflect.macros.BlackboxContext) = {
+ import c.universe._
+ q"""
+ trait Foo {
+ def x = 2
+ }
+ new Foo {}
+ """
+ }
+
+ def foo = macro impl
+} \ No newline at end of file
diff --git a/test/files/neg/macro-blackbox-structural/Test_2.scala b/test/files/neg/macro-blackbox-structural/Test_2.scala
new file mode 100644
index 0000000000..ea6a817e34
--- /dev/null
+++ b/test/files/neg/macro-blackbox-structural/Test_2.scala
@@ -0,0 +1,5 @@
+import Macros._
+
+object Test extends App {
+ println(Macros.foo.x)
+} \ No newline at end of file