fix: Scala 3.8 forward compatibility for context bounds and build config#1069
Closed
He-Pin wants to merge 1 commit into
Closed
fix: Scala 3.8 forward compatibility for context bounds and build config#1069He-Pin wants to merge 1 commit into
He-Pin wants to merge 1 commit into
Conversation
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
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tuple.yes,ev,OutIsTuple,ClassTag,LogSourcewith implicit vals in scope-Ywarn-dead-code/-Xlintto Scala 2-only, add-Wconfsuppressions for Scala 3, make-language:_conditional, replace-Xfatal-warningswith-WerrorDetails
Context bound fixes (routing DSL)
Directive.scala: ConjunctionMagnet, or, validatedMap, tmap, tcollect, Directive0SupportPathMatcher.scala: provide, apply (context bound[L: Tuple]→ explicitimplicit 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 ClassTagRejectionHandler.scala(javadsl): ClassTag with server.Rejection type annotationPoolInterface.scala,StageLoggingWithOverride.scala: LogSource context boundsTestRouteResult.scala,RouteTest.scala: ClassTag context boundsTest code fixes
EntityStreamingSpec.scala: context parameter passing via implicit valsBuild config fixes
project/Common.scala: Scala 2/3 conditional scalacOptions, -Wconf suppressionsbuild.sbt: conditional-language:_,-Werrorin docsDontLeakActorsOnFailingConnectionSpecs.scala,MultiNodeConfig.scala: Logging fixesNote:
private[this]→privateand= _→ explicit defaults are in a separate PR (#1068).Test plan
sbt "++ 2.13 Test/compile"passessbt "++ 3.3 Test/compile"passesMotivation
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"passessbt "++ 3.3 Test/compile"passesReferences
None - Scala 3.8 forward compatibility. Supersedes #1067 (split into #1068 + this PR).