diff --git a/implicits/src-2/upickle/implicits/internal/Macros.scala b/implicits/src-2/upickle/implicits/internal/Macros.scala index 15a341ddb..db3b5b6dd 100644 --- a/implicits/src-2/upickle/implicits/internal/Macros.scala +++ b/implicits/src-2/upickle/implicits/internal/Macros.scala @@ -345,10 +345,9 @@ object Macros { def write(i: Int) = { val snippet = q""" - this.writeSnippet[R, ${argTypes(i)}]( - ${c.prefix}.objectAttributeKeyWriteMap, + this.writeSnippetMappedName[R, ${argTypes(i)}]( ctx, - ${mappedArgs(i)}, + ${c.prefix}.objectAttributeKeyWriteMap(${mappedArgs(i)}), implicitly[${c.prefix}.Writer[${argTypes(i)}]], v.${TermName(rawArgs(i))} ) diff --git a/implicits/src-3/upickle/implicits/macros.scala b/implicits/src-3/upickle/implicits/macros.scala index da4fdde64..adb5224e9 100644 --- a/implicits/src-3/upickle/implicits/macros.scala +++ b/implicits/src-3/upickle/implicits/macros.scala @@ -144,9 +144,8 @@ def writeSnippetsImpl[R, T, WS <: Tuple](thisOuter: Expr[upickle.core.Types with val select = Select.unique(v.asTerm, rawLabel.name).asExprOf[Any] val snippet = '{ ${self}.writeSnippet[R, tpe]( - ${thisOuter}.objectAttributeKeyWriteMap, ${ctx}, - ${Expr(label)}, + ${thisOuter}.objectAttributeKeyWriteMap(${Expr(label)}), summonInline[Tuple.Elem[WS, index]], ${select}, ) diff --git a/implicits/src/upickle/implicits/CaseClassReadWriters.scala b/implicits/src/upickle/implicits/CaseClassReadWriters.scala index 6fa0dd814..3226d3115 100644 --- a/implicits/src/upickle/implicits/CaseClassReadWriters.scala +++ b/implicits/src/upickle/implicits/CaseClassReadWriters.scala @@ -24,6 +24,7 @@ trait CaseClassReadWriters extends upickle.core.Types{ @deprecated("Not used, left for binary compatibility") def writeToObject[R](ctx: ObjVisitor[_, R], v: V): Unit + @scala.annotation.nowarn def write0[R](out: Visitor[_, R], v: V): R = { if (v == null) out.visitNull(-1) else { @@ -33,16 +34,24 @@ trait CaseClassReadWriters extends upickle.core.Types{ } } + def writeSnippetMappedName[R, V](ctx: _root_.upickle.core.ObjVisitor[_, R], + mappedArgsI: CharSequence, + w: Any, + value: Any) = { + val keyVisitor = ctx.visitKey(-1) + ctx.visitKeyValue( + keyVisitor.visitString(mappedArgsI, -1) + ) + ctx.narrow.visitValue(w.asInstanceOf[Writer[Any]].write(ctx.subVisitor, value), -1) + } + + @deprecated("Not used, left for binary compatibility") def writeSnippet[R, V](objectAttributeKeyWriteMap: CharSequence => CharSequence, ctx: _root_.upickle.core.ObjVisitor[_, R], mappedArgsI: String, w: Any, value: Any) = { - val keyVisitor = ctx.visitKey(-1) - ctx.visitKeyValue( - keyVisitor.visitString(objectAttributeKeyWriteMap(mappedArgsI), -1) - ) - ctx.narrow.visitValue(w.asInstanceOf[Writer[Any]].write(ctx.subVisitor, value), -1) + writeSnippetMappedName(ctx, objectAttributeKeyWriteMap(mappedArgsI), w, value) } }