From 2777e9f01b6c9d61656cd3780828a69aaa2942c0 Mon Sep 17 00:00:00 2001 From: Jacob Wang Date: Thu, 2 Dec 2021 10:07:20 +0000 Subject: [PATCH] update magnolia to new namespace --- build.sbt | 6 +++--- .../scala-2.13/difflicious/DifferGen.scala | 18 +++++++++--------- .../main/scala-3/difflicious/DifferGen.scala | 4 +++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/build.sbt b/build.sbt index 29d4770..ad886d2 100644 --- a/build.sbt +++ b/build.sbt @@ -36,9 +36,9 @@ lazy val core = Project("difflicious-core", file("modules/core")) .settings(commonSettings) .settings( libraryDependencies ++= Seq( - if (isScala3.value) "com.softwaremill.magnolia1_3" %% "magnolia" % "1.0.0-M4" + if (isScala3.value) "com.softwaremill.magnolia1_3" %% "magnolia" % "1.0.0-M7" // if (isScala3.value) "com.softwaremill.magnolia" %% "magnolia-core" % "2.0.0-M7-SNAPSHOT" - else "com.softwaremill.magnolia" %% "magnolia-core" % "1.0.0-M4", + else "com.softwaremill.magnolia1_2" %% "magnolia" % "1.0.0-M7", "dev.zio" %% "izumi-reflect" % "1.1.2", "com.lihaoyi" %% "fansi" % "0.2.14", ) ++ ( @@ -114,7 +114,7 @@ lazy val docs: Project = project val orig = (ThisProject / makeMicrosite).taskValue if (isScala3.value) Def.task({}) else Def.task(orig.value) - }.value + }.value, ) .settings( mdocIn := file("docs/docs"), diff --git a/modules/core/src/main/scala-2.13/difflicious/DifferGen.scala b/modules/core/src/main/scala-2.13/difflicious/DifferGen.scala index 36114ff..a35c75a 100644 --- a/modules/core/src/main/scala-2.13/difflicious/DifferGen.scala +++ b/modules/core/src/main/scala-2.13/difflicious/DifferGen.scala @@ -3,7 +3,7 @@ import difflicious.DiffResult.MismatchTypeResult import difflicious.differ.RecordDiffer import difflicious.internal.EitherGetSyntax._ import difflicious.utils.TypeName.SomeTypeName -import magnolia._ +import magnolia1._ import scala.collection.mutable import scala.collection.immutable.ListMap @@ -11,7 +11,7 @@ import scala.collection.immutable.ListMap trait DifferGen { type Typeclass[T] = Differ[T] - def combine[T](ctx: ReadOnlyCaseClass[Differ, T]): Differ[T] = { + def join[T](ctx: ReadOnlyCaseClass[Differ, T]): Differ[T] = { new RecordDiffer[T]( ctx.parameters .map { p => @@ -40,17 +40,17 @@ trait DifferGen { override def diff(inputs: DiffInput[T]): DiffResult = inputs match { case DiffInput.ObtainedOnly(obtained) => - ctx.dispatch(obtained)(sub => sub.typeclass.diff(DiffInput.ObtainedOnly(sub.cast(obtained)))) + ctx.split(obtained)(sub => sub.typeclass.diff(DiffInput.ObtainedOnly(sub.cast(obtained)))) case DiffInput.ExpectedOnly(expected) => - ctx.dispatch(expected)(sub => sub.typeclass.diff(DiffInput.ExpectedOnly(sub.cast(expected)))) + ctx.split(expected)(sub => sub.typeclass.diff(DiffInput.ExpectedOnly(sub.cast(expected)))) case DiffInput.Both(obtained, expected) => { - ctx.dispatch(obtained) { obtainedSubtype => - ctx.dispatch(expected) { expectedSubtype => + ctx.split(obtained) { obtainedSubtype => + ctx.split(expected) { expectedSubtype => if (obtainedSubtype.typeName.short == expectedSubtype.typeName.short) { obtainedSubtype.typeclass .diff( obtainedSubtype.cast(obtained), - expectedSubtype.cast(expected).asInstanceOf[obtainedSubtype.SType] + expectedSubtype.cast(expected).asInstanceOf[obtainedSubtype.SType], ) } else { MismatchTypeResult( @@ -129,12 +129,12 @@ trait DifferGen { } - def dispatch[T](ctx: SealedTrait[Differ, T]): Differ[T] = + def split[T](ctx: SealedTrait[Differ, T]): Differ[T] = new SealedTraitDiffer[T](ctx, isIgnored = false) def derived[T]: Differ[T] = macro Magnolia.gen[T] - private def toDiffliciousTypeName(typeName: magnolia.TypeName): SomeTypeName = { + private def toDiffliciousTypeName(typeName: magnolia1.TypeName): SomeTypeName = { difflicious.utils.TypeName( long = typeName.full, short = typeName.short, diff --git a/modules/core/src/main/scala-3/difflicious/DifferGen.scala b/modules/core/src/main/scala-3/difflicious/DifferGen.scala index d518c1d..2476a4a 100644 --- a/modules/core/src/main/scala-3/difflicious/DifferGen.scala +++ b/modules/core/src/main/scala-3/difflicious/DifferGen.scala @@ -21,7 +21,7 @@ trait DifferGen extends Derivation[Differ]: isIgnored = false, typeName = toDiffliciousTypeName(ctx.typeInfo) ) - + override def split[T](ctx: SealedTrait[Differ, T]): Differ[T] = new SealedTraitDiffer(ctx, isIgnored = false) @@ -70,6 +70,7 @@ trait DifferGen extends Derivation[Differ]: subtypes = IArray(newSubtypes.toArray: _*), annotations = ctx.annotations, typeAnnotations = ctx.typeAnnotations, + isEnum = ctx.isEnum, ) new SealedTraitDiffer[T](newSealedTrait, isIgnored = newIgnored) @@ -99,6 +100,7 @@ trait DifferGen extends Derivation[Differ]: subtypes = newSubtypes, annotations = ctx.annotations, typeAnnotations = ctx.typeAnnotations, + isEnum = ctx.isEnum, ) new SealedTraitDiffer[T](newSealedTrait, isIgnored) }