Skip to content

Commit

Permalink
Fix 2.12 build
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszKubuszok committed Dec 16, 2023
1 parent 35a6faa commit acc512e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ trait ProductTypesPlatform extends ProductTypes { this: DefinitionsPlatform =>
val (constructorArguments, _) = checkArguments[A](parameters, arguments)

val methodType: ?? = args.foldRight[??](Type[A].as_??) { (paramList, resultType) =>
val paramTypes = paramList.view.values.map(_.Underlying.tpe).toList
val paramTypes = paramList.values.map(_.Underlying.tpe).toList
// tq returns c.Tree, to turn it to c.Type we need .tpe, which without a .typecheck is null
fromUntyped(c.typecheck(tq"(..$paramTypes) => ${resultType.Underlying.tpe}", mode = c.TYPEmode).tpe).as_??
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,20 @@ private[chimney] trait DslMacroUtils {
case Left(_) => Right(List(params))
case Right(tail) => Right(params :: tail)
}
// Scala 2.12
// case Apply(_, params) =>
// TODO: ???

Check warning on line 97 in chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala

View check run for this annotation

Codecov / codecov/patch

chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala#L97

Added line #L97 was not covered by tests
// TODO: remove once everything works
case _ =>
println(s"""Expression:
|${Console.MAGENTA}${show(t)}${Console.RESET}
|defined as:

Check warning on line 102 in chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala

View check run for this annotation

Codecov / codecov/patch

chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala#L102

Added line #L102 was not covered by tests
|${Console.MAGENTA}${showRaw(t)}${Console.RESET}
|of type:

Check warning on line 104 in chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala

View check run for this annotation

Codecov / codecov/patch

chimney/src/main/scala-2/io/scalaland/chimney/internal/compiletime/dsl/utils/DslMacroUtils.scala#L104

Added line #L104 was not covered by tests
|${Console.MAGENTA}${t.tpe}${Console.RESET}
|of type:
|${Console.MAGENTA}${showRaw(t.tpe)}${Console.RESET}
|""".stripMargin)
Left(invalidConstructor(t))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ class TotalTransformerCustomConstructorSpec extends ChimneySpec {

def customConstructor(x: Int, z: (Double, Double)): Bar = Bar(x * 2, (z._1 * 2, z._2 * 2))

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))
// Scala 2.12 :/
// 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 acc512e

Please sign in to comment.