diff options
author | Jakob Odersky <jakob@driver.xyz> | 2018-06-29 17:56:06 -0700 |
---|---|---|
committer | Jakob Odersky <jakob@odersky.com> | 2018-06-30 00:32:44 -0700 |
commit | c4dd18f810afdb4adb85d002ad34e660fe54c146 (patch) | |
tree | dc2c3b8f51009a96c9be7cd5831e8ce3280caa6b /shared/src/main/scala/DerivedFormats.scala | |
parent | 9545fe93dfe68974ca4bf2f9e6310216fc914e15 (diff) | |
download | spray-json-derivation-c4dd18f810afdb4adb85d002ad34e660fe54c146.tar.gz spray-json-derivation-c4dd18f810afdb4adb85d002ad34e660fe54c146.tar.bz2 spray-json-derivation-c4dd18f810afdb4adb85d002ad34e660fe54c146.zip |
Fix bug in derivation of classes with type parametersv0.4.6
Diffstat (limited to 'shared/src/main/scala/DerivedFormats.scala')
-rw-r--r-- | shared/src/main/scala/DerivedFormats.scala | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/shared/src/main/scala/DerivedFormats.scala b/shared/src/main/scala/DerivedFormats.scala index 03e632f..6ea7c4b 100644 --- a/shared/src/main/scala/DerivedFormats.scala +++ b/shared/src/main/scala/DerivedFormats.scala @@ -18,7 +18,8 @@ trait DerivedFormats { self: BasicFormats => override def write(value: T): JsValue = { val fields: Seq[(String, JsValue)] = ctx.parameters.map { param => extractFieldName(param.label) -> param.typeclass.write( - param.dereference(value)) + param.dereference(value) + ) } JsObject(fields: _*) } @@ -40,7 +41,8 @@ trait DerivedFormats { self: BasicFormats => } case js => deserializationError( - s"Cannot read JSON '$js' as a ${ctx.typeName.full}") + s"Cannot read JSON '$js' as a ${ctx.typeName.full}" + ) } } @@ -57,7 +59,8 @@ trait DerivedFormats { self: BasicFormats => case obj: JsObject => JsObject( (Map(typeFieldName -> JsString(sub.typeName.short)) ++ - obj.fields).toSeq: _*) + obj.fields).toSeq: _* + ) case js => js } } @@ -71,7 +74,8 @@ trait DerivedFormats { self: BasicFormats => case _ => deserializationError( s"Cannot deserialize JSON to ${ctx.typeName.full} " + - "because serialized type cannot be determined.") + "because serialized type cannot be determined." + ) } ctx.subtypes.find(_.typeName.short == typeName) match { @@ -79,7 +83,8 @@ trait DerivedFormats { self: BasicFormats => case None => deserializationError( s"Cannot deserialize JSON to ${ctx.typeName.full} " + - s"because type '${typeName}' is unsupported.") + s"because type '${typeName}' is unsupported." + ) } } } @@ -117,7 +122,7 @@ object DerivedFormatMacros { /** Utility that converts a magnolia-generated JsonFormat to a RootJsonFormat. */ def derivedFormat[T: c.WeakTypeTag](c: Context): c.Tree = { import c.universe._ - val tpe = weakTypeOf[T].typeSymbol.asType + val tpe = weakTypeOf[T] val sprayPkg = c.mirror.staticPackage("spray.json") val valName = TermName(c.freshName("format")) q"""{ |