scodec - Method too large

152 Views Asked by At

Have a sealed trait DataTag and its subtypes (86 case classes). After upgrade project to scala 2.12, scodec-core 1.11.8 and scodec-bits 1.1.27, compilation fail with

[error] Method too large: protocol/Payload/BasePacket$.tagCodec ()Lscodec/Codec;

The error is called by this method:

implicit def tagCodec: Codec[DataTag] = Codec.coproduct[DataTag].auto

Is there an alternative way to generate codec with a large number of subtypes?

I tried to use the "key based discriminators" example (https://github.com/scodec/scodec/blob/series/1.11.x/unitTests/src/test/scala/scodec/examples/CoproductsExample.scala), but the result is the same.

P.S.: I made an issue on github(https://github.com/scodec/scodec/issues/324), but no one has answered it yet.

1

There are 1 best solutions below

0
On

Problem solved. Codec wrote, specifying all codecs from subtypes сompanion objects through .typecase(discriminator, codec). This is ugly, but works.