The basic problem is that with enum A: case B, Calling implicit def rw: RW[A] = macroR will end up looking for a R[B], which will trigger superTypeReader[B, A], which picks up the rw we are defining and becoming an infinite recursion/loop.
The fix here is to ensure that when calling macroR[T]/macroW[T]/macroRW[T], that superTypeReader and superTypeWriter do not trigger on type [_, T]. We can do that by requiring that they take a NotGiven[CurrentlyDeriving[T]], and providing an implicit CurrentlyDeriving[T] in the macroR/macroW/macroRW bodies.
Added some compileError tests to ensure these raise implicit not found errors as expected
While superTypeWriter/superTypeReader had their signatures changed, the fact that they are inline means there are no binary compatibility concerns
This is only necessary for Scala 3, since Scala 2 doesn't have superTypeWriter/superTypeReader in the first place due to diverging implicit issues (see https://github.com/com-lihaoyi/upickle/pull/459)
Fixes https://github.com/com-lihaoyi/upickle/issues/468
The basic problem is that with
enum A: case B
, Callingimplicit def rw: RW[A] = macroR
will end up looking for aR[B]
, which will triggersuperTypeReader[B, A]
, which picks up therw
we are defining and becoming an infinite recursion/loop.The fix here is to ensure that when calling
macroR[T]
/macroW[T]
/macroRW[T]
, thatsuperTypeReader
andsuperTypeWriter
do not trigger on type[_, T]
. We can do that by requiring that they take aNotGiven[CurrentlyDeriving[T]]
, and providing an implicitCurrentlyDeriving[T]
in themacroR
/macroW
/macroRW
bodies.Added some
compileError
tests to ensure these raise implicit not found errors as expectedWhile
superTypeWriter
/superTypeReader
had their signatures changed, the fact that they areinline
means there are no binary compatibility concernsThis is only necessary for Scala 3, since Scala 2 doesn't have
superTypeWriter
/superTypeReader
in the first place due to diverging implicit issues (see https://github.com/com-lihaoyi/upickle/pull/459)