Skip to content

Commit

Permalink
Avoid instance name collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
travisbrown committed Jun 12, 2019
1 parent 6b99cb3 commit 8a27b32
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ abstract class JsonCodecMacros {
)
} else {
val tparamNames = tparams.map(_.name)
def mkImplicitParams(typeSymbol: TypeSymbol) =
def mkImplicitParams(prefix: String, typeSymbol: TypeSymbol) =
tparamNames.zipWithIndex.map {
case (tparamName, i) =>
val paramName = TermName(s"instance$i")
val paramName = TermName(s"$prefix$i")
val paramType = tq"$typeSymbol[$tparamName]"
q"$paramName: $paramType"
}
val decodeParams = mkImplicitParams(DecoderClass)
val encodeParams = mkImplicitParams(EncoderClass)
val decodeParams = mkImplicitParams("decode", DecoderClass)
val encodeParams = mkImplicitParams("encode", EncoderClass)
val Type = tq"$tpname[..$tparamNames]"
(
q"""implicit def $decodeName[..$tparams](implicit ..$decodeParams): $DecoderClass[$Type] =
Expand Down

0 comments on commit 8a27b32

Please sign in to comment.