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
and this compiles on Scala 2, but it creates cyclic reference on Scala 3.
The reason for that is that summon is called before checking whether we are on top level and that is easy to fix:
valsummoned=if (!top) Expr.summon[Schema[T]] elseNone
summoned match {
caseSome(schema) =>
instead of
Expr.summon[Schema[T]] match {
caseSome(schema) if!top =>
but that still does not work because Mirror(typeRepr) returnsNone for a type like that (I guess it is also trying to summon the implicit for T under the hood).
If the macro does not get the Mirror (just generates null for example) then the code with the above workaround compiles on Scala 3, so I believe a derive macro that does not rely on Mirror would solve this issue
The text was updated successfully, but these errors were encountered:
Original problem:
The following does not work:
while if we let the compiler to use the type generated by
DeriveSchema
it does:The problem is that Scala 3 does not compile this, requiring all implicits to have explicit type annotation (which is the first version).
We could do the following trick to work around this:
and this compiles on Scala 2, but it creates cyclic reference on Scala 3.
The reason for that is that
summon
is called before checking whether we are on top level and that is easy to fix:instead of
but that still does not work because
Mirror(typeRepr)
returnsNone
for a type like that (I guess it is also trying to summon the implicit forT
under the hood).If the macro does not get the
Mirror
(just generatesnull
for example) then the code with the above workaround compiles on Scala 3, so I believe a derive macro that does not rely onMirror
would solve this issueThe text was updated successfully, but these errors were encountered: