You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem here is that all of circe-generic is built on Shapeless's LabelledGeneric instances, and Shapeless does not provide instances when the val is present:
scala> shapeless.LabelledGeneric[SuperType.SubType1.type]
res0: shapeless.LabelledGeneric[SuperType.SubType1.type]{typeRepr= shapeless.HNil} = shapeless.LabelledGeneric$$anon$1@3e8417fb
scala> shapeless.LabelledGeneric[SuperType.SubType2.type]
<console>:28:error: could not find implicit value for parameter lgen: shapeless.LabelledGeneric[SuperType.SubType2.type]
shapeless.LabelledGeneric[SuperType.SubType2.type]
^
You might want to open an issue about this on the Shapeless side, and if Shapeless ever starts providing instances in these cases, everything should just work on the circe side.
Hi, there is an error when I used 'val' field overridden below. I am using circle 0.9.0-M2.
sealed trait SuperType {
def name: String
}
object SuperType {
object SubType1 extends SuperType {
override def name: String = "type1"
//override val name: String = "type1" //not work when using 'val'
}
object SubType2 extends SuperType {
override def name: String = "type2"
//override val name: String = "type2" //not work when using 'val'
}
}
implicit val superTypeEncoder = deriveEnumerationEncoder[SuperType]
I can get around it by using 'def' instead of 'val' at the moment. Thanks.
Cheng
The text was updated successfully, but these errors were encountered: