Scala Macro Libraries
While being experimental, the Scala community has largely adopted the Scala 2 Def Macro feature in multiple of ways: code generation, optimizations, ergonomic DSLs...
A large part of the ecosystem now depends on Scala 2.13 macros defined in external libraries. Identifying those library dependencies is key to establish that a project is ready to be migrated to Scala 3.
The Scala 3 compiler cannot execute Scala 2.13 macro definitions.
However, the handy
-Xignore-scala2-macros
option can be used to ignore them and type check the rest of the code.
[error] -- Error: /src/main/scala/foo/Foo.scala:10:45 [error] 10 | implicit val foo: Foo[List[Int]] = Foo.make [error] | ^ [error] |Scala 2 macro cannot be used in Scala 3. See https://dotty.epfl.ch/docs/reference/dropped-features/macros.html [error] |To turn this error into a warning, pass -Xignore-scala2-macros to the compiler
Beware that
-Xignore-scala2-macros
will produce bytecode that will fail at runtime.
Macro Libraries
The following table contains an incomplete list of macro libraries and their migration status.
If you find any macro library that is not listed here you are invited to open an issue.
Macro Annotations Libraries
Macro annotations are not supported in Scala 3. The following table contains a incomplete list of Scala 2.13 libraries that provide macro annotations. Scala 3 compatible alternatives are proposed when available.
Project | Alternative Solutions |
---|---|
dmytromitin/auxify | |
julianpeeters/avro-scala-macro-annotations | |
manatki/derevo | |
typelevel/simulacrum | Source generation using simulacrum-scalafix |