-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macro implementations cannot have implicit parameters other than WeakTypeTag evidences #396
Comments
Hm did you use the exact same examples? They are part of the build so should work jsut fine. Can you post the full code that causes the problem? |
HI thanks for the feedback, I found this discussion https://gitter.im/propensive/magnolia?at=5e82194b49e7a8130cdaf16b, turns out I just need to add trait RandomObjectDerivation {
type Typeclass[A] = RandomObject[A]
def join[A](caseClass: CaseClass[Typeclass, A]): Typeclass[A] = new Typeclass[A] {
def generate(): A = caseClass.construct(_.typeclass.generate())
}
def split[A](sealedTrait: SealedTrait[Typeclass, A]): Typeclass[A] = new Typeclass[A] {
def generate(): A = choice(sealedTrait.subtypes).typeclass.generate()
}
def split[T](ctx: SealedTrait[Typeclass, T]): Typeclass[T] =
new Typeclass[T] {
def generate(): T = choice(ctx.subtypes).typeclass.generate()
}
private def choice[A](xs: Seq[A]): A =
xs.toIndexedSeq(Random.nextInt(xs.length))
implicit def gen[A]: Typeclass[A] = macro Magnolia.gen[A]
} |
Yes, in Scala 3 you can use implicits or I suppose you'll need to have some sources scala2 and some scala3 specific (see e.g. tapir's |
Awesome, I followed this tutorial https://docs.scala-lang.org/scala3/guides/migration/tutorial-macro-cross-building.html |
Hi, I tried to use some examples in https://github.com/softwaremill/magnolia/tree/scala2/examples/src/main/scala/magnolia1/examples with scala 2.13 but I got the compilation error below:
Did I miss out something or the issue is real?
Thanks in advance for your help.
Best regards,
Vu Hai
The text was updated successfully, but these errors were encountered: