magnolia
magnolia copied to clipboard
Support Java enums
This happened while calling magnolia to derive a typeclasse instance for com.google.bigtable.v2.Mutation.MutationCase:
<console>:16: error: exception during macro expansion:
scala.ScalaReflectionException: Java enum DELETE_FROM_FAMILY is not a type
at scala.reflect.api.Symbols$SymbolApi.asType(Symbols.scala:183)
at scala.reflect.api.Symbols$SymbolApi.asType$(Symbols.scala:183)
at scala.reflect.internal.Symbols$SymbolContextApiImpl.asType(Symbols.scala:94)
at magnolia.Magnolia$.$anonfun$gen$56(magnolia.scala:403)
at scala.collection.immutable.List.map(List.scala:283)
at magnolia.Magnolia$.directInferImplicit$1(magnolia.scala:402)
at magnolia.Magnolia$.$anonfun$gen$68(magnolia.scala:480)
at scala.Option.orElse(Option.scala:289)
at magnolia.Magnolia$.$anonfun$gen$1(magnolia.scala:480)
at magnolia.CompileTimeState$Stack$.withContext(magnolia.scala:627)
at magnolia.Magnolia$.gen(magnolia.scala:85)
at com.spotify.scio.coders.CoderMacros$.wrappedCoder(CoderMacros.scala:125)
While magnolia can't possibly derive an typeclasse instance for this type, it should still be able to use fallback instead.
I will fix the ugly error message but keep this issue open, because it might be possible to support enums (perhaps with a third abstraction next to CaseClass and SealedTrait). Someone would have to do the research though.