From 218cf1babedc302b54936f056edf1bd5fea92f20 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 7 Mar 2019 12:21:38 +0300 Subject: [PATCH] #44 fix compilation error on macro derivation --- build.sbt | 2 +- .../tethys/derivation/impl/derivation/ReaderDerivation.scala | 2 +- .../tethys/derivation/impl/derivation/WriterDerivation.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 985199c0..e2440f21 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ lazy val scalaTestVersion = "3.0.5" lazy val commonSettings = Seq( - version := "0.9.0", + version := "0.9.0.1", organization := "com.tethys-json", scalaVersion := "2.11.12", crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.0-M2"), diff --git a/modules/macro-derivation/src/main/scala/tethys/derivation/impl/derivation/ReaderDerivation.scala b/modules/macro-derivation/src/main/scala/tethys/derivation/impl/derivation/ReaderDerivation.scala index d1be750e..0eff8b2b 100644 --- a/modules/macro-derivation/src/main/scala/tethys/derivation/impl/derivation/ReaderDerivation.scala +++ b/modules/macro-derivation/src/main/scala/tethys/derivation/impl/derivation/ReaderDerivation.scala @@ -70,7 +70,7 @@ trait ReaderDerivation def deriveReader[A: WeakTypeTag](description: ReaderMacroDescription): Expr[JsonReader[A]] = { val tpe = weakTypeOf[A] val classDef = caseClassDefinition(tpe) - val config = c.eval(description.config) + val config = scala.util.Try(c.eval(description.config)).getOrElse(c.eval(description.config)) val readerFields = applyFieldStyle(config.fieldStyle) .andThen(applyOperations(description.operations)) diff --git a/modules/macro-derivation/src/main/scala/tethys/derivation/impl/derivation/WriterDerivation.scala b/modules/macro-derivation/src/main/scala/tethys/derivation/impl/derivation/WriterDerivation.scala index a6e87d72..4e3a61f6 100644 --- a/modules/macro-derivation/src/main/scala/tethys/derivation/impl/derivation/WriterDerivation.scala +++ b/modules/macro-derivation/src/main/scala/tethys/derivation/impl/derivation/WriterDerivation.scala @@ -74,7 +74,7 @@ trait WriterDerivation def deriveWriter[A: WeakTypeTag](description: MacroWriteDescription): Expr[JsonObjectWriter[A]] = { val tpe = description.tpe - val config = c.eval(description.config) + val config = scala.util.Try(c.eval(description.config)).getOrElse(c.eval(description.config)) val writerFields = applyFieldStyle(config.fieldStyle) .andThen(applyDescriptionOperations(description.operations)) .apply(makeFields[A])