Suppose there is a proto MyMessage and a type class TypeClass[T].
Is it possible to have a custom instance TypeClass[MyMessage] in the generated companion object of MyMessage, so any (implicit TypeClass[Message]) would get automatically resolved without any import?
The solution I've thought of is to have a trait defining the implicit instance
trait MyMessageCompanionTrait {
implicit val myMessageType = new TypeClass[MyMessage] = ???
}
and then make that extend the companion object
message MyMessage {
option (scalapb.message).companion_extends = "MyMessageCompanionTrait";
int32 field = 1;
}
Obviously this adds a circular dependency in the build.