Scala 3 Migration guide

Scala 3 Migration guide

  • User Guide
  • Contribute
  • GitHub

›Resources

Compatibility Reference

  • Introduction

Tooling

  • Scala 3 Migrate Plugin

Resources

  • Scala Macro Libraries
  • Moving from Scala 2 to Scala 3
Edit

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.

ProjectStatusComments
adamw/scala-macro-debug
ajozwik/quill-generic
argonaut-io/argonautSince version 6.3.2
backuity/ansi-interpolator
typelevel/log4catsSince version 1.3.1
circe/circeSince version 0.14.0
dmytromitin/auxify
fthomas/refinedrefined macros not yet available
jokade/slogging
getquill/quillSince version 3.13.0
giiita/refuelSince version 2.0.2
lightbend/scala-loggingSince version 3.9.4
lihaoyi/autowire
lihaoyi/fastparseSince version 3.0.0
lihaoyi/mill
lihaoyi/pprintSince version 0.6.0
lihaoyi/sourcecodeSince version 0.1.8
lihaoyi/upickleSince version 1.2.0
lihaoyi/utestSince version 0.7.3
lloydmeta/enumeratumSince version 1.7.1
log4s/log4sSince version 1.10.0-M1
macro-peg/macro_peg
milessabin/shapelessBeing rewritten into Shapeless 3
Since version 3.0.0 (typelevel/shapeless-3)
monix/minitestSince 2.9.0
mpollmeier/gremlin-scalamacros module not available for Scala 3.0
nevillelyh/parquet-avro-extra
non/imp
optics-dev/MonocleSince 3.0.0
payalabs/scalajs-react-bridge
playframework/play-jsonSince version 2.10.0-RC5
plokhotnyuk/expression-evaluatorNo replacement for Evals.eval
plokhotnyuk/fast-string-interpolatorSince version 0.6.2
plokhotnyuk/jsoniter-scalaSince version 2.12.1
softwaremill/magnoliaSince version 1.0.0
pureconfig/pureconfigSince version 0.17.2
sangria-graphql/sangriaSince version 3.3.0
scalalandio/chimneySince version 0.8.0
scalameta/munitSince 0.3.0
scalatest/scalatestSince version 3.1.0
scalatest/scalatestplus-junitSince version 3.1.0
scalikejdbc/scalikejdbcSince 4.0.0
scodec/scodec-bitsSince version 1.1.18
sirthias/parboiled2Since version 2.4.0
sirthias/borerSince version 1.10.0
slick/slickSince version 3.5.0-M4
softwaremill/macwireSince version 2.4.0
thoughtworksinc/each
tersesystems/blindsightSince version 1.5.2
typelevel/claimantNo longer maintained
typelevel/spireSince version 0.18.0
wix/accordNo longer maintained
wvlet/airframeSince version 20.12.1
zio/izumi-reflectDoes not yet support path-dependent type
zio/zioSince version 1.0.4
zero-deps/protoSince version 2.1.0

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.

ProjectAlternative Solutions
dmytromitin/auxify
julianpeeters/avro-scala-macro-annotations
manatki/derevo
typelevel/simulacrum Source generation using simulacrum-scalafix

Contributors welcome!

← Scala 3 Migrate PluginMoving from Scala 2 to Scala 3 →
  • Macro Libraries
  • Macro Annotations Libraries
Scala 3 Migration guide
Docs
User GuideContribute
Community
Chat on GitterDiscuss on Scala Users
More
GitHub
Copyright © 2023 Scala Center