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
I have a typeclass which is generated using Mirrors. There is a compilation failure returned when I use UnionDerivation on top of it.
Take a look at this minimal example:
//>usingscala"3.5.2"//>usinglib"io.github.irevive::union-derivation-core:0.2.1"//>usingoptions"-Yretain-trees"importscala.annotation.nowarnimportscala.deriving.Mirrorimportio.github.irevive.union.derivation.IsUnionimportio.github.irevive.union.derivation.UnionDerivationtraitShow[A] {
defshow(value: A):String
}
objectShow {
inlinegivenderivedUnion[A](usingIsUnion[A]):Show[A] =UnionDerivation.derive[Show, A]
@nowarn("msg=New anonymous class definition will be duplicated at each inline site")
inlinegiveninstance[A](usingm: Mirror.ProductOf[A]):Show[A] = {
println(s"$m") // if you remove it, then it compilesnewShow[A] {
defshow(value: A):String= value.toString()
}
}
}
caseclassA(x: String)
caseclassB(y: Int)
// it also compiles when you uncomment those:// given Show[A] = Show.instance[A]// given Show[B] = Show.instance[B]@main defhello() = println(Show.derivedUnion[A|B].show(A("1")))
It returns
Error: Error while emitting example.scala
val m$proxy1
The error goes away if you either don't use the mirror (even if you declare it in using clause) or if you generate the instances outside of UnionDerivation macro.
The text was updated successfully, but these errors were encountered:
Since 3.3.0 it is going to fail scala/scala3#16804 when you use anything from this inlined param (like m.MirroredElemLabels) - see this for context.
(m : scala.deriving.Mirror.ProductOf[A]) is not a valid type prefix, since it is not an immutable path
[error] |Inline parameters are not considered immutable paths and cannot be used as
[error] |singleton types.
[error] |
[error] |Hint: Removing the `inline` qualifier from the `m` parameter
[error] |may help resolve this issue.
Hi,
I have a typeclass which is generated using Mirrors. There is a compilation failure returned when I use UnionDerivation on top of it.
Take a look at this minimal example:
It returns
The error goes away if you either don't use the mirror (even if you declare it in
using clause
) or if you generate the instances outside of UnionDerivation macro.The text was updated successfully, but these errors were encountered: