magnolia icon indicating copy to clipboard operation
magnolia copied to clipboard

Support Java enums

Open jto opened this issue 7 years ago • 1 comments

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.

jto avatar Aug 29 '18 15:08 jto

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.

joroKr21 avatar Jan 13 '20 00:01 joroKr21