summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/macro-reify-splice-splice.check1
-rw-r--r--test/files/run/macro-reify-splice-splice.flags1
-rw-r--r--test/files/run/macro-reify-splice-splice/Macros_1.scala11
-rw-r--r--test/files/run/macro-reify-splice-splice/Test_2.scala3
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled.check4
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled2.check4
-rw-r--r--test/files/run/t6355.check2
-rw-r--r--test/files/run/t6355.scala17
-rw-r--r--test/files/run/t7777.check7
-rw-r--r--test/files/run/t7777/Macros_1.scala17
-rw-r--r--test/files/run/t7777/Test_2.scala6
-rw-r--r--test/files/run/t8091.check1
-rw-r--r--test/files/run/t8091.scala4
-rw-r--r--test/files/run/t8104.check1
-rw-r--r--test/files/run/t8104/Macros_1.scala11
-rw-r--r--test/files/run/t8104/Test_2.scala16
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled.check4
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled2.check4
18 files changed, 90 insertions, 24 deletions
diff --git a/test/files/run/macro-reify-splice-splice.check b/test/files/run/macro-reify-splice-splice.check
deleted file mode 100644
index 3b18e512db..0000000000
--- a/test/files/run/macro-reify-splice-splice.check
+++ /dev/null
@@ -1 +0,0 @@
-hello world
diff --git a/test/files/run/macro-reify-splice-splice.flags b/test/files/run/macro-reify-splice-splice.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-reify-splice-splice.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-reify-splice-splice/Macros_1.scala b/test/files/run/macro-reify-splice-splice/Macros_1.scala
deleted file mode 100644
index 691f22ad07..0000000000
--- a/test/files/run/macro-reify-splice-splice/Macros_1.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
-
-object Macros {
- def foo = macro Impls.foo
-
- object Impls {
- def foo(c: Ctx) = c.universe.reify {
- { c.universe.reify(c.universe.reify("hello world")) }.splice.splice
- }
- }
-} \ No newline at end of file
diff --git a/test/files/run/macro-reify-splice-splice/Test_2.scala b/test/files/run/macro-reify-splice-splice/Test_2.scala
deleted file mode 100644
index f697da6020..0000000000
--- a/test/files/run/macro-reify-splice-splice/Test_2.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-object Test extends App {
- println(Macros.foo)
-} \ No newline at end of file
diff --git a/test/files/run/macro-typecheck-macrosdisabled.check b/test/files/run/macro-typecheck-macrosdisabled.check
index e0e880ab66..0579a4f4c8 100644
--- a/test/files/run/macro-typecheck-macrosdisabled.check
+++ b/test/files/run/macro-typecheck-macrosdisabled.check
@@ -1,4 +1,4 @@
-{
+({
val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe;
val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(this.getClass().getClassLoader());
$u.Expr.apply[Int(2)]($m, {
@@ -28,5 +28,5 @@
};
new $typecreator2()
}))
-}
+}: reflect.runtime.universe.Expr[Int])
ru.reify[Int](2)
diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check
index 347dfec1dc..c6e1c08d5d 100644
--- a/test/files/run/macro-typecheck-macrosdisabled2.check
+++ b/test/files/run/macro-typecheck-macrosdisabled2.check
@@ -1,4 +1,4 @@
-{
+({
val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe;
val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(this.getClass().getClassLoader());
$u.Expr.apply[Array[Int]]($m, {
@@ -28,5 +28,5 @@
};
new $typecreator2()
}))
-}
+}: reflect.runtime.universe.Expr[Array[Int]])
ru.reify[Array[Int]](scala.Array.apply(2))
diff --git a/test/files/run/t6355.check b/test/files/run/t6355.check
new file mode 100644
index 0000000000..ce74ab38a2
--- /dev/null
+++ b/test/files/run/t6355.check
@@ -0,0 +1,2 @@
+bippy(x: Int) called with x = 42
+bippy(x: String) called with x = "42"
diff --git a/test/files/run/t6355.scala b/test/files/run/t6355.scala
new file mode 100644
index 0000000000..f1921391a3
--- /dev/null
+++ b/test/files/run/t6355.scala
@@ -0,0 +1,17 @@
+import scala.language.dynamics
+
+class A extends Dynamic {
+ def applyDynamic(method: String): B = new B(method)
+}
+class B(method: String) {
+ def apply(x: Int) = s"$method(x: Int) called with x = $x"
+ def apply(x: String) = s"""$method(x: String) called with x = "$x""""
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val x = new A
+ println(x.bippy(42))
+ println(x.bippy("42"))
+ }
+}
diff --git a/test/files/run/t7777.check b/test/files/run/t7777.check
new file mode 100644
index 0000000000..162ff2d2a2
--- /dev/null
+++ b/test/files/run/t7777.check
@@ -0,0 +1,7 @@
+foo(1, 2)
+bar(4, 5)
+foo(3)
+bar(7)
+apply(6)
+apply(9)
+foo(8)
diff --git a/test/files/run/t7777/Macros_1.scala b/test/files/run/t7777/Macros_1.scala
new file mode 100644
index 0000000000..459ab3edbb
--- /dev/null
+++ b/test/files/run/t7777/Macros_1.scala
@@ -0,0 +1,17 @@
+import scala.language.experimental.macros
+import scala.language.dynamics
+import scala.reflect.macros.WhiteboxContext
+
+class DynMacro extends Dynamic {
+ def applyDynamic(s: String)(xs: Any*): DynMacro =
+ macro DynMacro.applyDynamicMacro
+}
+
+object DynMacro extends DynMacro {
+ def applyDynamicMacro(c: WhiteboxContext)(s: c.Expr[String])(xs: c.Expr[Any]*): c.Expr[DynMacro] = {
+ import c.universe._
+ val Literal(Constant(n: String)) = s.tree
+ val args = xs.map(_.tree.toString).mkString("(", ", ", ")")
+ c.Expr(q"println(${ n + args }); ${c.prefix.tree}")
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t7777/Test_2.scala b/test/files/run/t7777/Test_2.scala
new file mode 100644
index 0000000000..1fe8b63bab
--- /dev/null
+++ b/test/files/run/t7777/Test_2.scala
@@ -0,0 +1,6 @@
+object Test extends App {
+ DynMacro.foo(1, 2) // prints "foo(1, 2)"
+ DynMacro.foo(3).bar(4, 5) // prints "bar(4, 5)", then "foo(3)"
+ DynMacro(6).bar(7) // prints "bar(7)", then "apply(6)"
+ DynMacro.foo(8)(9) // Fails!
+} \ No newline at end of file
diff --git a/test/files/run/t8091.check b/test/files/run/t8091.check
new file mode 100644
index 0000000000..4c4e91774f
--- /dev/null
+++ b/test/files/run/t8091.check
@@ -0,0 +1 @@
+börk börk
diff --git a/test/files/run/t8091.scala b/test/files/run/t8091.scala
new file mode 100644
index 0000000000..cd412d4c2a
--- /dev/null
+++ b/test/files/run/t8091.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ val result = "börk börk" flatMap (ch ⇒ if (ch > 127) f"&#x${ch}%04x;" else "" + ch)
+ println(result)
+} \ No newline at end of file
diff --git a/test/files/run/t8104.check b/test/files/run/t8104.check
new file mode 100644
index 0000000000..c2593eb199
--- /dev/null
+++ b/test/files/run/t8104.check
@@ -0,0 +1 @@
+TypeTag[(Int, Int)]
diff --git a/test/files/run/t8104/Macros_1.scala b/test/files/run/t8104/Macros_1.scala
new file mode 100644
index 0000000000..21d81a3687
--- /dev/null
+++ b/test/files/run/t8104/Macros_1.scala
@@ -0,0 +1,11 @@
+import scala.reflect.macros.WhiteboxContext
+
+object Macros {
+ def impl[T](c: WhiteboxContext)(implicit T: c.WeakTypeTag[T]) = {
+ import c.universe._
+ import definitions._
+ val fields = T.tpe.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x }
+ val Repr = appliedType(TupleClass(fields.length).asType.toType, fields.map(_.typeSignature))
+ q"new Generic[$T]{ type Repr = $Repr }"
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t8104/Test_2.scala b/test/files/run/t8104/Test_2.scala
new file mode 100644
index 0000000000..630176f175
--- /dev/null
+++ b/test/files/run/t8104/Test_2.scala
@@ -0,0 +1,16 @@
+trait Generic[T] { type Repr }
+object Generic {
+ type Aux[T, Repr0] = Generic[T] { type Repr = Repr0 }
+ import scala.language.experimental.macros
+ implicit def materializeGeneric[T, Repr]: Generic.Aux[T, Repr] = macro Macros.impl[T]
+}
+
+object Test extends App {
+ case class C(x: Int, y: Int)
+
+ import scala.reflect.runtime.universe._
+ def reprify[T, Repr](x: T)(implicit generic: Generic.Aux[T, Repr], tag: TypeTag[Repr]) = println(tag)
+ reprify(C(40, 2))
+
+ implicitly[Generic.Aux[C, (Int, Int)]]
+}
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.check b/test/files/run/toolbox_typecheck_macrosdisabled.check
index 3de296f1ad..d9e79cdd19 100644
--- a/test/files/run/toolbox_typecheck_macrosdisabled.check
+++ b/test/files/run/toolbox_typecheck_macrosdisabled.check
@@ -1,4 +1,4 @@
-{
+({
val $u: ru.type = ru;
val $m: $u.Mirror = ru.runtimeMirror({
final class $anon extends scala.AnyRef {
@@ -37,5 +37,5 @@
};
new $typecreator2()
}))
-}
+}: ru.Expr[Int])
ru.reify[Int](2)
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check
index 9810946024..8e554a6c8f 100644
--- a/test/files/run/toolbox_typecheck_macrosdisabled2.check
+++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check
@@ -1,4 +1,4 @@
-{
+({
val $u: ru.type = ru;
val $m: $u.Mirror = ru.runtimeMirror({
final class $anon extends scala.AnyRef {
@@ -37,5 +37,5 @@
};
new $typecreator2()
}))
-}
+}: ru.Expr[Array[Int]])
ru.reify[Array[Int]](scala.Array.apply(2))