Skip to content

Commit

Permalink
Fix Scala 2.12 support for Eta-expansion in withConstructor
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszKubuszok committed Dec 16, 2023
1 parent acc512e commit bae8651
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,13 @@ private[chimney] trait DslMacroUtils {

def parse(t: Tree): Either[String, ExistentialCtor] = {
def extractParams(t: Tree): Either[String, List[List[ValDef]]] = t match {
// TODO: add support for multiple parameter lists
case Function(params, tail) =>
extractParams(tail) match {
case Left(_) => Right(List(params))
case Right(tail) => Right(params :: tail)
}
// Scala 2.12
// case Apply(_, params) =>
// TODO: ???
case Block(Nil, term) => extractParams(term)
// TODO: remove once everything works
case _ =>
println(s"""Expression:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class TotalTransformerCustomConstructorSpec extends ChimneySpec {
// .into[Bar]
// .withConstructor(customConstructor)
// .transform ==> Bar(6, (6.28, 6.28))
// Foo(3, "pi", (3.14, 3.14))
// .into[Bar]
// .withConstructor(customConstructor _)
// .transform ==> Bar(6, (6.28, 6.28))
Foo(3, "pi", (3.14, 3.14))
.into[Bar]
.withConstructor(customConstructor _)
.transform ==> Bar(6, (6.28, 6.28))
Foo(3, "pi", (3.14, 3.14))
.into[Bar]
.withConstructor({ (x: Int, z: (Double, Double)) =>
Expand Down

0 comments on commit bae8651

Please sign in to comment.