sksamuel / avro4s

Avro schema generation and serialization / deserialization for Scala
Apache License 2.0
719 stars 236 forks source link

Strange missing implicit compilation error #218

Closed Pierre1405 closed 5 years ago

Pierre1405 commented 6 years ago

Hello,

I had a very surprising compilation error with an even more surprising work around, I have 2 case class case class DeviceMessage(rinfos: List[ReceiverInfo]) case class ReceiverInfo(isNew: Option[Boolean] = Some(false))

and with the following code import java.io.ByteArrayOutputStream import com.sigfox.das.avro.models.v3.commons.models.device.DeviceMessage import com.sksamuel.avro4s.AvroOutputStream

class AvroProducerMessagePrintLn { val baos = new ByteArrayOutputStream() val output = AvroOutputStream.binary[DeviceMessage](baos) } I have this compilation error: Could not find implicit SchemaFor[com.sigfox.das.avro.models.v3.commons.models.device.DeviceMessage] val output = AvroOutputStream.binaryDeviceMessage

I found a workaround by replacing import com.sigfox.das.avro.models.v3.commons.models.device.DeviceMessage by import com.sigfox.das.avro.models.v3.commons.models.device.{ DeviceMessage, ReceiverInfo }

I think it's a scala compilation error and I'm not sure there is some way for you to avoid this error, but I thought I'm may be interesting to know this problem

I attach to the ticket a sbt project if you want to reproduce it or do more test. avro4sCompilationError.tar.gz

Thanks anyway for your work on avro4s

Regards, Pierre

yevgenius commented 6 years ago

Thanks for the workaround @Pierre1405 !

dave-handy commented 6 years ago

Just ran into this when updating to 1.9.0 from 1.8.3. Thanks for documenting this bug and the workaround!

Side note: change log for 1.9.0 would be nice