summaryrefslogtreecommitdiff
path: root/test/files/run/macro-enclosingowner-sbt
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2014-02-15 14:43:09 +0100
committerEugene Burmako <xeno.by@gmail.com>2014-02-15 14:59:35 +0100
commit5b6700fa3a6b05545aa9b2c0d0493a07897464a5 (patch)
tree1528c7708d327f8b2fe47aacf0ebbe5f911fcc96 /test/files/run/macro-enclosingowner-sbt
parent3bedb19f85e09b19567c7e77bf8ea5d2e4aeff2f (diff)
downloadscala-5b6700fa3a6b05545aa9b2c0d0493a07897464a5.tar.gz
scala-5b6700fa3a6b05545aa9b2c0d0493a07897464a5.tar.bz2
scala-5b6700fa3a6b05545aa9b2c0d0493a07897464a5.zip
adds more tests for enclosingOwners
Makes sure that it's possible to cover sbt's use cases, and also checks that we can distinguish vals from vars (should anyone ever need that).
Diffstat (limited to 'test/files/run/macro-enclosingowner-sbt')
-rw-r--r--test/files/run/macro-enclosingowner-sbt/Macros_1.scala14
-rw-r--r--test/files/run/macro-enclosingowner-sbt/Test_2.scala23
2 files changed, 37 insertions, 0 deletions
diff --git a/test/files/run/macro-enclosingowner-sbt/Macros_1.scala b/test/files/run/macro-enclosingowner-sbt/Macros_1.scala
new file mode 100644
index 0000000000..a98a984861
--- /dev/null
+++ b/test/files/run/macro-enclosingowner-sbt/Macros_1.scala
@@ -0,0 +1,14 @@
+import scala.reflect.macros.whitebox._
+import scala.language.experimental.macros
+
+object Macros {
+ def impl(c: Context) = {
+ import c.universe._
+ def enclosingName(sym: Symbol): String = {
+ sym.name.toString.stripSuffix(termNames.LOCAL_SUFFIX_STRING)
+ }
+ q"println(${enclosingName(c.internal.enclosingOwner).toString}); 42"
+ }
+
+ def foo: Int = macro impl
+} \ No newline at end of file
diff --git a/test/files/run/macro-enclosingowner-sbt/Test_2.scala b/test/files/run/macro-enclosingowner-sbt/Test_2.scala
new file mode 100644
index 0000000000..58521d9429
--- /dev/null
+++ b/test/files/run/macro-enclosingowner-sbt/Test_2.scala
@@ -0,0 +1,23 @@
+object Test extends App {
+ val a1 = Macros.foo
+ val a2 = Predef.identity(Predef.identity(Macros.foo))
+ val a3: Int = Macros.foo
+ val a4: Int = Predef.identity(Predef.identity(Macros.foo))
+
+ var b1 = Macros.foo
+ var b2 = Predef.identity(Predef.identity(Macros.foo))
+ var b3: Int = Macros.foo
+ var b4: Int = Predef.identity(Predef.identity(Macros.foo))
+
+ def c1 = Macros.foo
+ def c2 = Predef.identity(Predef.identity(Macros.foo))
+ def c3: Int = Macros.foo
+ def c4: Int = Predef.identity(Predef.identity(Macros.foo))
+ c1; c2; c3; c4;
+
+ lazy val d1 = Macros.foo
+ lazy val d2 = Predef.identity(Predef.identity(Macros.foo))
+ lazy val d3: Int = Macros.foo
+ lazy val d4: Int = Predef.identity(Predef.identity(Macros.foo))
+ d1; d2; d3; d4
+} \ No newline at end of file