diff options
author | Heather Miller <heather.miller@epfl.ch> | 2012-04-15 14:51:18 +0200 |
---|---|---|
committer | Heather Miller <heather.miller@epfl.ch> | 2012-04-15 14:51:18 +0200 |
commit | e4bea920b42eaa526a9e07ad001f17443d6abeba (patch) | |
tree | c786202cc9d0fa5b1a26dfd8e1154cacca7fbaf4 /test/files/run/macro-basic-ma-mdmi | |
parent | 23aa1a8d7b08b767f90657baf9bc13a355682671 (diff) | |
parent | 364dd41c3e0e33afe6c3ec6e0c04f1d345c4b6ca (diff) | |
download | scala-e4bea920b42eaa526a9e07ad001f17443d6abeba.tar.gz scala-e4bea920b42eaa526a9e07ad001f17443d6abeba.tar.bz2 scala-e4bea920b42eaa526a9e07ad001f17443d6abeba.zip |
Merge branch 'master' of https://github.com/scala/scala into wip-sip14-fixes
Diffstat (limited to 'test/files/run/macro-basic-ma-mdmi')
-rw-r--r-- | test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala | 32 | ||||
-rw-r--r-- | test/files/run/macro-basic-ma-mdmi/Test_2.scala | 4 |
2 files changed, 36 insertions, 0 deletions
diff --git a/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala new file mode 100644 index 0000000000..44bfe861e3 --- /dev/null +++ b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala @@ -0,0 +1,32 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + Expr[Int](body) + } + + def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + Expr[Int](body) + } + + def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + Expr[Int](body) + } +} + +object Macros { + object Shmacros { + def foo(x: Int): Int = macro Impls.foo + } + def bar(x: Int): Int = macro Impls.bar +} + +class Macros { + def quux(x: Int): Int = macro Impls.quux +}
\ No newline at end of file diff --git a/test/files/run/macro-basic-ma-mdmi/Test_2.scala b/test/files/run/macro-basic-ma-mdmi/Test_2.scala new file mode 100644 index 0000000000..e9a10e20c9 --- /dev/null +++ b/test/files/run/macro-basic-ma-mdmi/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + import Macros.Shmacros._ + println(foo(2) + Macros.bar(2) * new Macros().quux(4)) +}
\ No newline at end of file |