Skip to content

fix: Scala 3.8 forward compatibility for context bounds and build config#1069

Closed
He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:scala38-context-bounds
Closed

fix: Scala 3.8 forward compatibility for context bounds and build config#1069
He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:scala38-context-bounds

Conversation

@He-Pin

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

Copy link
Copy Markdown
Member

Summary

  • Fix context bound patterns for Scala 3.8 compatibility: replace explicit passing of Tuple.yes, ev, OutIsTuple, ClassTag, LogSource with implicit vals in scope
  • Update build config: move -Ywarn-dead-code/-Xlint to Scala 2-only, add -Wconf suppressions for Scala 3, make -language:_ conditional, replace -Xfatal-warnings with -Werror

Details

Context bound fixes (routing DSL)

  • Directive.scala: ConjunctionMagnet, or, validatedMap, tmap, tcollect, Directive0Support
  • PathMatcher.scala: provide, apply (context bound [L: Tuple] → explicit implicit ev)
  • PathDirectives.scala: rawPathPrefix, pathSuffix (tprovide with explicit type param)
  • FutureDirectives.scala: OnSuccessMagnet (Tuple import fix for scala.Tuple shadowing)

Context bound fixes (core)

  • HttpMessage.scala: getHeaders ClassTag
  • RejectionHandler.scala (javadsl): ClassTag with server.Rejection type annotation
  • PoolInterface.scala, StageLoggingWithOverride.scala: LogSource context bounds
  • TestRouteResult.scala, RouteTest.scala: ClassTag context bounds

Test code fixes

  • EntityStreamingSpec.scala: context parameter passing via implicit vals

Build config fixes

  • project/Common.scala: Scala 2/3 conditional scalacOptions, -Wconf suppressions
  • build.sbt: conditional -language:_, -Werror in docs
  • DontLeakActorsOnFailingConnectionSpecs.scala, MultiNodeConfig.scala: Logging fixes

Note: private[this]private and = _ → explicit defaults are in a separate PR (#1068).

Test plan

  • sbt "++ 2.13 Test/compile" passes
  • sbt "++ 3.3 Test/compile" passes

Motivation

Scala 3.8 introduces breaking changes for context parameter passing. These changes ensure forward compatibility.

Modification

Replace explicit context parameter passing with implicit vals in scope; conditionally configure scalac options per Scala version.

Result

All modules compile cleanly on Scala 2.13.18 and 3.3.8, with source compatibility for Scala 3.8's context parameter changes.

Tests

  • sbt "++ 2.13 Test/compile" passes
  • sbt "++ 3.3 Test/compile" passes

References

None - Scala 3.8 forward compatibility. Supersedes #1067 (split into #1068 + this PR).

Motivation:
Scala 3.8 changes how context parameters work: context bound evidence
can no longer be passed explicitly using the old syntax. Additionally,
several scalac flags (-language:_, -Ywarn-dead-code) are Scala 2-only.

Modification:
- Fix context bound patterns: replace explicit passing (Tuple.yes, ev,
  OutIsTuple, ClassTag, LogSource) with implicit vals in scope
- Fix routing DSL: Directive (or, validatedMap, tmap, tcollect),
  PathMatcher (provide, apply), PathDirectives (rawPathPrefix,
  pathSuffix), FutureDirectives (OnSuccessMagnet)
- Fix core: HttpMessage.getHeaders ClassTag, RejectionHandler ClassTag,
  PoolInterface/StageLoggingWithOverride LogSource
- Fix testkit: TestRouteResult, RouteTest ClassTag bounds
- Build config: move -Ywarn-dead-code/-Xlint to Scala 2-only, add
  -Wconf suppressions for Scala 3, make -language:_ conditional,
  replace -Xfatal-warnings with -Werror in docs
- Fix test code: EntityStreamingSpec implicit passing

Result:
All modules compile cleanly on Scala 2.13.18 and 3.3.8, with source
compatibility for Scala 3.8's context parameter changes.

Tests:
- sbt "++ 2.13 Test/compile" passes
- sbt "++ 3.3 Test/compile" passes

References:
None - Scala 3.8 forward compatibility
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.

1 participant