diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-10-02 16:34:59 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-10-02 22:45:58 +0200 |
commit | d627672ec4a10861a659bfaacfaf86aa4b5b4e6e (patch) | |
tree | fd8e9af80295bac892e9e684ef4945d9761a3352 /test/files/run | |
parent | 8aae23ed47c4e38a465ff3373392484ca82473d1 (diff) | |
download | scala-d627672ec4a10861a659bfaacfaf86aa4b5b4e6e.tar.gz scala-d627672ec4a10861a659bfaacfaf86aa4b5b4e6e.tar.bz2 scala-d627672ec4a10861a659bfaacfaf86aa4b5b4e6e.zip |
clearly establishes what macro bundles are
Previously it was enough to just extend scala.reflect.macros.Macro, which
created some loopholes, but now scalac enforces that bundles:
1) Are static (not necessarily top-level, but just static)
2) Are traits (objects shouldn't be bundles anyway, and classes bring
complications with their ctors which require special treatment in
generated classes, so why support them if they don't bring anything
new to the table?)
3) Are monomorphic (again, this brings unnecessary complications wrt
auxiliary code generation, so I don't see merit in supporting
polymorphic bundles, whatever that a polymorphic bundle could mean)
4) Don't provide concrete implementation for Macro.c (if they do then
what is the point?)
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/macro-bundle-static.check | 6 | ||||
-rw-r--r-- | test/files/run/macro-bundle-static/Impls_Macros_1.scala | 31 | ||||
-rw-r--r-- | test/files/run/macro-bundle-static/Test_2.scala | 8 | ||||
-rw-r--r-- | test/files/run/macro-bundle-toplevel.check | 6 | ||||
-rw-r--r-- | test/files/run/macro-bundle-toplevel.flags (renamed from test/files/run/macro-bundle.flags) | 0 | ||||
-rw-r--r-- | test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala (renamed from test/files/run/macro-bundle/Impls_Macros_1.scala) | 13 | ||||
-rw-r--r-- | test/files/run/macro-bundle-toplevel/Test_2.scala (renamed from test/files/run/macro-bundle/Test_2.scala) | 3 | ||||
-rw-r--r-- | test/files/run/macro-bundle.check | 3 |
8 files changed, 67 insertions, 3 deletions
diff --git a/test/files/run/macro-bundle-static.check b/test/files/run/macro-bundle-static.check new file mode 100644 index 0000000000..37c8eaf27a --- /dev/null +++ b/test/files/run/macro-bundle-static.check @@ -0,0 +1,6 @@ +() +Int +() +true +IntInt +true diff --git a/test/files/run/macro-bundle-static/Impls_Macros_1.scala b/test/files/run/macro-bundle-static/Impls_Macros_1.scala new file mode 100644 index 0000000000..831dac6df5 --- /dev/null +++ b/test/files/run/macro-bundle-static/Impls_Macros_1.scala @@ -0,0 +1,31 @@ +import scala.reflect.macros.Context +import scala.reflect.macros.Macro +import scala.language.experimental.macros + +object Enclosing { + trait Impl extends Macro { + def mono = c.literalUnit + def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString) + def weird = macro mono + } +} + +object Macros { + def mono = macro Enclosing.Impl.mono + def poly[T] = macro Enclosing.Impl.poly[T] +} + +package pkg { + object Enclosing { + trait Impl extends Macro { + def mono = c.literalTrue + def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString + c.weakTypeOf[T].toString) + def weird = macro mono + } + } + + object Macros { + def mono = macro Enclosing.Impl.mono + def poly[T] = macro Enclosing.Impl.poly[T] + } +}
\ No newline at end of file diff --git a/test/files/run/macro-bundle-static/Test_2.scala b/test/files/run/macro-bundle-static/Test_2.scala new file mode 100644 index 0000000000..72160f6ec2 --- /dev/null +++ b/test/files/run/macro-bundle-static/Test_2.scala @@ -0,0 +1,8 @@ +object Test extends App { + println(Macros.mono) + println(Macros.poly[Int]) + println(new Enclosing.Impl{val c = ???}.weird) + println(pkg.Macros.mono) + println(pkg.Macros.poly[Int]) + println(new pkg.Enclosing.Impl{val c = ???}.weird) +}
\ No newline at end of file diff --git a/test/files/run/macro-bundle-toplevel.check b/test/files/run/macro-bundle-toplevel.check new file mode 100644 index 0000000000..37c8eaf27a --- /dev/null +++ b/test/files/run/macro-bundle-toplevel.check @@ -0,0 +1,6 @@ +() +Int +() +true +IntInt +true diff --git a/test/files/run/macro-bundle.flags b/test/files/run/macro-bundle-toplevel.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-bundle.flags +++ b/test/files/run/macro-bundle-toplevel.flags diff --git a/test/files/run/macro-bundle/Impls_Macros_1.scala b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala index 3f651c9a43..676935682e 100644 --- a/test/files/run/macro-bundle/Impls_Macros_1.scala +++ b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala @@ -10,4 +10,17 @@ trait Impl extends Macro { object Macros { def mono = macro Impl.mono def poly[T] = macro Impl.poly[T] +} + +package pkg { + trait Impl extends Macro { + def mono = c.literalTrue + def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString + c.weakTypeOf[T].toString) + def weird = macro mono + } + + object Macros { + def mono = macro Impl.mono + def poly[T] = macro Impl.poly[T] + } }
\ No newline at end of file diff --git a/test/files/run/macro-bundle/Test_2.scala b/test/files/run/macro-bundle-toplevel/Test_2.scala index 428f809f9d..139cc5bef2 100644 --- a/test/files/run/macro-bundle/Test_2.scala +++ b/test/files/run/macro-bundle-toplevel/Test_2.scala @@ -2,4 +2,7 @@ object Test extends App { println(Macros.mono) println(Macros.poly[Int]) println(new Impl{val c = ???}.weird) + println(pkg.Macros.mono) + println(pkg.Macros.poly[Int]) + println(new pkg.Impl{val c = ???}.weird) }
\ No newline at end of file diff --git a/test/files/run/macro-bundle.check b/test/files/run/macro-bundle.check deleted file mode 100644 index 2107454960..0000000000 --- a/test/files/run/macro-bundle.check +++ /dev/null @@ -1,3 +0,0 @@ -() -Int -() |