diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/pos/t8411/Macros_1.scala | 10 | ||||
-rw-r--r-- | test/files/pos/t8411/Test_2.scala | 4 | ||||
-rw-r--r-- | test/files/scalacheck/quasiquotes/TypecheckedProps.scala | 5 |
3 files changed, 19 insertions, 0 deletions
diff --git a/test/files/pos/t8411/Macros_1.scala b/test/files/pos/t8411/Macros_1.scala new file mode 100644 index 0000000000..c5319c559c --- /dev/null +++ b/test/files/pos/t8411/Macros_1.scala @@ -0,0 +1,10 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macros { + def defaultZeroCase(pf: PartialFunction[Int, Int]): PartialFunction[Int, Int] = macro impl + def impl(c: Context)(pf: c.Tree) = { import c.universe._ + val q"{ case ..$cases }" = pf + q"{ case ..$cases case _ => 0 }" + } +} diff --git a/test/files/pos/t8411/Test_2.scala b/test/files/pos/t8411/Test_2.scala new file mode 100644 index 0000000000..a0ad30f0f5 --- /dev/null +++ b/test/files/pos/t8411/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val pf = Macros.defaultZeroCase { case 1 => 2 } + assert(pf(2) == 0) +} diff --git a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala index 7c4cb0306e..fb2eb69321 100644 --- a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala +++ b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala @@ -152,4 +152,9 @@ object TypecheckedProps extends QuasiquoteProperties("typechecked") { assert(name == defName) assert(rhs ≈ defRhs) } + + property("partial function") = test { + val q"{ case ..$cases }: $ascr" = typecheck(q"{ case 1 => () }: PartialFunction[Int, Unit]") + assert(cases ≈ q"{ case 1 => () }".cases) + } } |