Skip to content

Fix Scala 3.8+ compilation warnings for forward compatibility#528

Merged
He-Pin merged 1 commit into
mainfrom
scala39-compat
Jun 14, 2026
Merged

Fix Scala 3.8+ compilation warnings for forward compatibility#528
He-Pin merged 1 commit into
mainfrom
scala39-compat

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 14, 2026

Copy link
Copy Markdown
Member

Motivation

Scala 3.8+ introduces new deprecation warnings that prevent clean compilation under forward-looking Scala versions (3.8.x / 3.9.x). These warnings need to be addressed for forward compatibility with Scala 3.9.x while maintaining cross-build support for Scala 2.13.x and 3.3.x.

Modification

  • Move Scala 2-only compiler options (-Xlog-reflective-calls, -Ydelambdafy:method) out of shared scalacOptions into the Scala 2 conditional block to eliminate "bad option" warnings in Scala 3
  • Add -Wconf suppressions for Scala 3.8+ warnings that cannot be fixed with cross-version compatible syntax:
    • Implicit parameters should use using clause (requires using keyword, Scala 3 only)
    • _ deprecated for wildcard type arguments (? is Scala 3.4+ only)
    • Trailing _ for eta-expansion (removal requires Scala 3-only syntax in some contexts)
    • with as type operator deprecated (& intersection type operator)
    • Unreachable case except for null
    • Bad option -Yfuture-lazy-vals on Scala 3.8+

Result

All 74 compiler warnings eliminated when compiling with Scala 3.8.4. Scala 2.13.18 compilation remains unaffected. Production Scala versions unchanged (2.13.18 / 3.3.8). No behavioral changes to the runtime.

Tests

  • sbt "++3.8.4" "core / compile" — 0 warnings (previously 74)
  • sbt "++2.13.18" "core / compile" — success, no new warnings

References

Refs apache/pekko#3065 - None - Forward compatibility for Scala 3.8+/3.9.x

Motivation:
Scala 3.8+ introduces new deprecation warnings for patterns like implicit
parameter passing without `using`, wildcard type arguments with `_`,
trailing ` _` for eta-expansion, and `with` as a type operator. These
warnings need to be addressed for forward compatibility with Scala 3.9.x
while maintaining cross-build support for Scala 2.13.x and 3.3.x.

Modification:
- Move Scala 2-only compiler options (-Xlog-reflective-calls,
  -Ydelambdafy:method) out of shared scalacOptions into the Scala 2
  conditional block
- Add -Wconf suppressions for Scala 3.8+ warnings that cannot be fixed
  with cross-version compatible syntax (implicit using clause, wildcard
  type arguments, eta-expansion trailing underscore, with type operator,
  unreachable case except for null)

Result:
All 74 compiler warnings eliminated when compiling with Scala 3.8.4.
Scala 2.13.18 compilation remains unaffected. No behavioral changes.

Tests:
- sbt "++3.8.4" "core / compile" — 0 warnings (previously 74)
- sbt "++2.13.18" "core / compile" — success, no new warnings

References:
Refs apache/pekko#3065

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@He-Pin He-Pin merged commit e06f2d3 into main Jun 14, 2026
19 checks passed
@He-Pin He-Pin deleted the scala39-compat branch June 14, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants