Closed bertlebee closed 1 year ago
This would be incredible. By far the biggest obstacle when migrating to Scala 3. Here's a related issue: https://github.com/lampepfl/dotty/issues/14891#issuecomment-1094355021
I believe we can consider this implemented via https://github.com/lampepfl/dotty/pull/16392 and https://github.com/lampepfl/dotty/pull/16454, so I'll go ahead and close. If there are further ideas please do open a discussion here.
Very surprised that nobody has raised this before, so figured I'd better.
Currently, macro annotations are not supported in scala 3.
Some of the functionality can be achieved with typeclass derivation and/or
Selectable
machinery, but it's amazingly awkward, suffers from the limitations ofSelectable
, and anything that's generated doesn't make it to the class definition.Something that integrates nicely/reuses with both the existing quoting/splicing and lower level reflect API would be ideal, but it'd be great to be able to generate any code that you can write (as part of compilation, so people are unable to modify the generated code).
Related:
Scala 2 macro annotation docs: https://docs.scala-lang.org/overviews/macros/annotations.html
An old blog post that mentioned it could be done (I just assumed it hadn't been implemented yet) https://www.scala-lang.org/blog/2018/04/30/in-a-nutshell.html
An example of a 2.x use case: https://zio.dev/version-1.x/howto/use-zio-macros/