From 04c55c8d467097d69f3b2d7995e6f1d767b7e7ed Mon Sep 17 00:00:00 2001 From: Denys Shabalin Date: Mon, 24 Feb 2014 16:03:20 +0100 Subject: SI-8332 implicit class param unquoting in quasiquotes A new api that simplifies handling of implicit parameters has been mistakingly supporting just methods parameters. This commit adds support for class parameters too. --- .../quasiquotes/DefinitionConstructionProps.scala | 5 +++++ .../quasiquotes/DefinitionDeconstructionProps.scala | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'test/files/scalacheck') diff --git a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala index c6ad453c45..69aef12668 100644 --- a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala @@ -85,6 +85,11 @@ trait ClassConstruction { self: QuasiquoteProperties => property("SI-8333") = test { assertEqAst(q"{ $NoMods class C }", "{ class C }") } + + property("SI-8332") = test { + val args = q"val a: Int; val b: Int" + assertEqAst(q"class C(implicit ..$args)", "class C(implicit val a: Int, val b: Int)") + } } trait TraitConstruction { self: QuasiquoteProperties => diff --git a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala index 996ac65b36..af7f2164a0 100644 --- a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala @@ -73,8 +73,11 @@ trait ClassDeconstruction { self: QuasiquoteProperties => property("exhaustive class matcher") = test { def matches(line: String) { - val q"""$classMods class $name[..$targs] $ctorMods(...$argss) - extends { ..$early } with ..$parents { $self => ..$body }""" = parse(line) + val tree = parse(line) + val q"""$classMods0 class $name0[..$targs0] $ctorMods0(...$argss0) + extends { ..$early0 } with ..$parents0 { $self0 => ..$body0 }""" = tree + val q"""$classMods1 class $name1[..$targs1] $ctorMods1(...$argss1)(implicit ..$impl) + extends { ..$early1 } with ..$parents1 { $self1 => ..$body1 }""" = tree } matches("class Foo") matches("class Foo[T]") @@ -106,6 +109,13 @@ trait ClassDeconstruction { self: QuasiquoteProperties => Ident(TypeName("Int")), EmptyTree))), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(()))))))) } } + + property("SI-8332") = test { + val q"class C(implicit ..$args)" = q"class C(implicit i: I, j: J)" + val q"$imods val i: I" :: q"$jmods val j: J" :: Nil = args + assert(imods.hasFlag(IMPLICIT)) + assert(jmods.hasFlag(IMPLICIT)) + } } trait ModsDeconstruction { self: QuasiquoteProperties => -- cgit v1.2.3