Scala 3.8 forward compatibility for routing DSL and build config#1067
Closed
He-Pin wants to merge 4 commits into
Closed
Scala 3.8 forward compatibility for routing DSL and build config#1067He-Pin wants to merge 4 commits into
He-Pin wants to merge 4 commits into
Conversation
Motivation: Scala 3.8 introduces breaking changes for context parameter passing, private[this] deprecation, = _ deprecation, and various syntax updates. These changes ensure the codebase compiles cleanly on Scala 3.8+ while maintaining compatibility with Scala 2.13.x and 3.3.x. Modification: - Fix context bound patterns: replace explicit passing (Tuple.yes, ev, OutIsTuple, ClassTag) with implicit vals in scope for Scala 3.8 compat - Replace private[this] with private across ~37 files - Replace = _ with explicit defaults (= null, = 0L) across ~47 files - Add -Wconf suppressions for Scala 3-specific syntax warnings - Move -Ywarn-dead-code and -Xlint to Scala 2-only config blocks - Make -language:_ conditional for Scala 2 only - Fix Logging context bounds (PoolInterface, StageLoggingWithOverride) - Fix ClassTag context bounds (HttpMessage.getHeaders, RejectionHandler) - Fix Tuple import conflict in FutureDirectives (scala.Tuple shadowing) - Fix PathMatcher provide/apply with explicit implicit params - Fix PathDirectives tprovide with explicit type parameter - Fix refutable pattern in val (HttpHeaderParserSpec) - Replace -Xfatal-warnings with -Werror in docs module - Fix test code context parameter passing (EntityStreamingSpec) Result: All modules compile cleanly on Scala 3.8.4 with zero errors while maintaining full compatibility with Scala 2.13.x and 3.3.x.
Motivation: The PR apache#1067 changes to PathMatcher.scala introduced `implicit val tupleEv` and `implicit val tupleL` declarations that shadow the `ev` member of the PathMatcher class inside anonymous class bodies, causing "ambiguous implicit values" compilation errors on Scala 2.13. Modification: Remove the redundant implicit val declarations and pass the Tuple evidence explicitly to the PathMatcher constructor instead. For `repeat` and `optional`, pass `lift.OutIsTuple` directly. For `provide` and `apply`, pass `ev` directly and also pass it explicitly to `Matched` calls. Result: PathMatcher.scala compiles without ambiguous implicit errors on Scala 2.13 while maintaining Scala 3 forward compatibility. Tests: Not run - compilation fix References: Refs apache#1067
Member
|
scala 2.13 compile is broken |
Contributor
|
Would be good to create separate PRs for the separate kinds of issues to make it easier to review / verify |
Motivation: Scala 2.13 reports ambiguous implicit values when `provide` and `apply` explicitly pass `(ev)` to both the PathMatcher constructor and Matched case class, creating two `ev: Tuple[L]` candidates in scope (method parameter and constructor val). Modification: Remove explicit `(ev)` from constructor calls and Matched invocations in `provide` and `apply`, letting implicit resolution pick up `ev` from the method's implicit parameter — matching the behavior of the original `[L: Tuple]` context bound pattern. Result: PathMatcher compiles cleanly on both Scala 2.13.18 and 3.3.8 with no ambiguous implicit errors. Tests: - sbt "++ 2.13.18; http/compile" passes - sbt "++ 3.3.8; http/compile" passes - sbt "++ 2.13.18; http-tests/Test/testOnly ...PathDirectivesSpec" 222 passed - sbt "++ 2.13.18; http-tests/Test/testOnly ...EntityStreamingSpec" 11 passed References: Refs apache#1067
Member
Author
|
Thanks, I will split this PR |
2 tasks
Member
Author
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,ClassTagwith implicit vals in scopeprivate[this]withprivate(~37 files) and= _with explicit defaults (~47 files)-Ywarn-dead-code/-Xlintto Scala 2-only, add-Wconfsuppressions for Scala 3, make-language:_conditional, replace-Xfatal-warningswith-WerrorDetails
Context bound fixes
Directive.scala: ConjunctionMagnet, or, validatedMap, tmap, tcollect, Directive0SupportPathMatcher.scala: provide, apply, Matched case class constructionPathDirectives.scala: rawPathPrefix, pathSuffix (tprovide with explicit type param)FutureDirectives.scala: OnSuccessMagnet (Tuple import fix for scala.Tuple shadowing)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
HttpHeaderParserSpec.scala: refutable pattern in val → asInstanceOfEntityStreamingSpec.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 fixesVerified: all modules compile cleanly on Scala 3.8.4 (zero errors) while maintaining full compatibility with Scala 2.13.18 and 3.3.8.
Test plan
sbt "++ 3.8.4; Test/compile"passes with zero errorssbt "++ 3.3.8; http/compile"passes with zero errors