diff options
author | Paul Phillips <paulp@improving.org> | 2013-05-11 12:06:03 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-05-11 12:06:03 -0700 |
commit | 616417b0b0e46a4bb4c80cbe6bf805bb22803afe (patch) | |
tree | 933382adf12fa5fe32f832d0b5edf7b53358598e /test | |
parent | 082ca2ea97dd925d688ad6ec813f9bbfae12598f (diff) | |
parent | 5751ddd9eee0573dcf889983b423397fb6670415 (diff) | |
download | scala-616417b0b0e46a4bb4c80cbe6bf805bb22803afe.tar.gz scala-616417b0b0e46a4bb4c80cbe6bf805bb22803afe.tar.bz2 scala-616417b0b0e46a4bb4c80cbe6bf805bb22803afe.zip |
Merge pull request #2505 from scalamacros/topic/macros
some fixes for macros: one esoteric, and one quite critical
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/macro-system-properties.check | 26 | ||||
-rw-r--r-- | test/files/run/macro-system-properties.scala | 16 |
2 files changed, 42 insertions, 0 deletions
diff --git a/test/files/run/macro-system-properties.check b/test/files/run/macro-system-properties.check new file mode 100644 index 0000000000..dce976df02 --- /dev/null +++ b/test/files/run/macro-system-properties.check @@ -0,0 +1,26 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> import language.experimental._, reflect.macros.Context +import language.experimental._ +import reflect.macros.Context + +scala> object GrabContext { + def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context]) + // System.properties lets you stash true globals (unlike statics which are classloader scoped) + def impl(c: Context)() = { System.getProperties.put("lastContext", c); c.literalUnit } + def grab() = macro impl + } +defined module GrabContext + +scala> object Test { class C(implicit a: Any) { GrabContext.grab } } +defined module Test + +scala> object Test { class C(implicit a: Any) { GrabContext.grab } } +defined module Test + +scala> + +scala> diff --git a/test/files/run/macro-system-properties.scala b/test/files/run/macro-system-properties.scala new file mode 100644 index 0000000000..e182defc81 --- /dev/null +++ b/test/files/run/macro-system-properties.scala @@ -0,0 +1,16 @@ +import scala.tools.nsc._ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + import language.experimental._, reflect.macros.Context + object GrabContext { + def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context]) + // System.properties lets you stash true globals (unlike statics which are classloader scoped) + def impl(c: Context)() = { System.getProperties.put("lastContext", c); c.literalUnit } + def grab() = macro impl + } + object Test { class C(implicit a: Any) { GrabContext.grab } } + object Test { class C(implicit a: Any) { GrabContext.grab } } + """ +} |