Skip to content

Commit

Permalink
Bump pprint to 0.7.1
Browse files Browse the repository at this point in the history
Pprint is currently released for 2.11/2.12/2.13 and 3
  • Loading branch information
tgodzik committed Jan 10, 2022
1 parent 5a5097a commit 7cf396a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
8 changes: 3 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,9 @@ lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
moduleName := "metaconfig-core",
libraryDependencies ++= List(
"org.typelevel" %%% "paiges-core" % "0.4.2",
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.5.0"
) :+ (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => "com.lihaoyi" %%% "pprint" % "0.5.4"
case _ => "com.lihaoyi" %%% "pprint" % "0.6.6"
})
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.5.0",
"com.lihaoyi" %%% "pprint" % "0.7.1"
)
)
.settings(
libraryDependencies += {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class Macros(val c: blackbox.Context) {

val field = q"""new ${weakTypeOf[Field]}(
${param.name.decodedName.toString},
$tpeString.render,
$tpeString.render.render,
_root_.scala.List.apply(..$finalAnnots),
$underlying
)"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private[generic] def deriveSurfaceImpl[T: Type](using q: Quotes) =
fieldType.asType match
case '[t] =>
val renderer = Expr.summon[pprint.TPrint[t]].get
'{ $renderer.render }
'{ $renderer.render.render }

val fieldExpr = '{
new Field($fieldName, $tpeString, $finalAnnots, $underlying)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package metaconfig
import java.io.File
import metaconfig.generic.Settings
import metaconfig.generic.Surface
import pprint.TPrintColors

class DeriveSurfaceSuite extends munit.FunSuite {

Expand Down Expand Up @@ -76,13 +77,20 @@ class DeriveSurfaceSuite extends munit.FunSuite {
case class CustomTypePrinting(a: Int, b: Option[Int], c: List[String])
test("tprint") {
import pprint.TPrint
implicit val intPrint = TPrint.literal[Int]("number")
implicit val intPrint = new TPrint[Int] {
def render(implicit tpc: TPrintColors): fansi.Str = fansi.Str("number")
}
implicit def optionPrint[T](implicit ev: TPrint[T]): TPrint[Option[T]] =
TPrint.make { implicit colors => "(" + ev.render + ")" }
new TPrint[Option[T]] {
def render(implicit tpc: TPrintColors): fansi.Str =
"(" + ev.render + ")"
}
implicit def iterablePrint[C[x] <: Iterable[x], T](
implicit ev: TPrint[T]
): TPrint[C[T]] =
TPrint.make { implicit colors => "[" + ev.render + " ...]" }
): TPrint[C[T]] = new TPrint[C[T]] {
def render(implicit tpc: TPrintColors): fansi.Str =
"[" + ev.render + " ...]"
}
implicit val surface = generic.deriveSurface[CustomTypePrinting]
val a :: b :: c :: Nil = Settings[CustomTypePrinting].settings
assertEquals(a.tpe, "number")
Expand Down

0 comments on commit 7cf396a

Please sign in to comment.