diff options
author | Denys Shabalin <denys.shabalin@typesafe.com> | 2014-01-16 12:01:30 +0100 |
---|---|---|
committer | Denys Shabalin <denys.shabalin@typesafe.com> | 2014-01-16 12:45:38 +0100 |
commit | 8e9862473abd03bded2d3afa60c777099f7872c5 (patch) | |
tree | df2b1fcbd893a77ea63717f6290146357214b3cf /test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala | |
parent | 393829489a1e352c2ed659b16b6bea24069f4f9a (diff) | |
download | scala-8e9862473abd03bded2d3afa60c777099f7872c5.tar.gz scala-8e9862473abd03bded2d3afa60c777099f7872c5.tar.bz2 scala-8e9862473abd03bded2d3afa60c777099f7872c5.zip |
SI-8076 improve support for implicit argument list
This adds support for construction and deconstruction
of implicit argument list which was originally suggested
by @cvogt.
1. Splicing vale into implicit argument list automatically
adds implicit flag to them:
val x = q"val x: Int"
q"def foo(implicit $x)"
// <=> q"def foo(implicit x: Int)"
2. One might extract implicit argument list separately from
other argument lists:
val q”def foo(...$argss)(implicit ..$impl)" =
q"def foo(implicit x: Int)
// argss is Nil, impl contains valdef for x
But this doesn't require you to always extract it separatly:
val q”def foo(...$argss)" =
q"def foo(implicit x: Int)
// argss contains valdef for x
Diffstat (limited to 'test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala')
-rw-r--r-- | test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala index 2af656c7c9..3166eb7a99 100644 --- a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala @@ -7,6 +7,7 @@ object DefinitionConstructionProps with TraitConstruction with TypeDefConstruction with ValDefConstruction + with DefConstruction with PackageConstruction { property("SI-6842") = test { val x: Tree = q"val x: Int" @@ -349,4 +350,16 @@ trait PackageConstruction { self: QuasiquoteProperties => assertEqAst(q"package object foo extends { ..$edefs } with Any", "package object foo extends { val x = 1; type I = Int } with Any") } -}
\ No newline at end of file +} + +trait DefConstruction { self: QuasiquoteProperties => + property("construct implicit args (1)") = test { + val x = q"val x: Int" + assertEqAst(q"def foo(implicit $x) = x", "def foo(implicit x: Int) = x") + } + + property("construct implicit args (2)") = test { + val xs = q"val x1: Int" :: q"val x2: Long" :: Nil + assertEqAst(q"def foo(implicit ..$xs) = x1 + x2", "def foo(implicit x1: Int, x2: Long) = x1 + x2") + } +} |