Scala 3 Migration Compile Errors in CI
Compiling Scala 2 code under Scala 3 surfaces real incompatibilities - removed syntax, stricter implicit resolution, and Scala-2-only macro libraries. These are genuine source/dependency issues, not transient failures.
What this error means
Switching scalaVersion to 3.x produces compile errors that did not occur on 2.13 - symbol literals, old do/while/procedure syntax, ambiguous implicits, or a macro library with no Scala 3 artifact.
[error] -- Error: App.scala:10 ---
[error] 10 | 'foo
[error] | ^^^^
[error] | symbol literal 'foo is no longer supported,
[error] | use a string literal "foo" or an application Symbol("foo") insteadCommon causes
Dropped or changed Scala 3 syntax
Scala 3 removed constructs (symbol literals, procedure syntax) and tightened others, so valid Scala 2 code fails to compile.
Macro libraries / dependencies not on Scala 3
A dependency built only for Scala 2.13 (especially macro-heavy libraries) has no Scala 3 artifact, so resolution or compilation fails.
How to fix it
Use the migration mode to auto-rewrite
Scala 3’s migration flag rewrites many incompatibilities for you.
// build.sbt
scalaVersion := "3.3.3"
scalacOptions += "-source:3.3-migration"
// then: sbt "compile" to apply suggested rewritesUpdate dependencies to Scala 3 builds
- Bump libraries to versions that publish Scala 3 artifacts.
- For Scala-2-only deps, use
withDottyCompat/CrossVersion.for3Use2_13where the library is binary-compatible. - Replace macro libraries that have no Scala 3 equivalent.
How to prevent it
- Migrate with
-source:Nx-migrationto surface and auto-fix issues. - Audit dependencies for Scala 3 artifacts before switching.
- Migrate module by module rather than the whole build at once.