You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by he...@apache.org on 2026/06/15 03:45:16 UTC
(pekko-http) 01/01: fix: resolve implicit ambiguity in PathMatcher and reformat
This is an automated email from the ASF dual-hosted git repository.
He-Pin pushed a commit to branch scala39-compat
in repository https://gitbox.apache.org/repos/asf/pekko-http.git
commit 861b0e22d92d2e3244b1ce20c88f90aeb2ade5cb
Author: 虎鸣 <he...@alibaba-inc.com>
AuthorDate: Mon Jun 15 11:44:58 2026 +0800
fix: resolve implicit ambiguity in PathMatcher and reformat
Motivation:
Local implicit val tupleEv conflicted with PathMatcher's constructor
implicit ev, causing "ambiguous implicit values" on Scala 2.13.
Modification:
- Pass implicit Tuple explicitly where ambiguity arises
- Reformat StageLoggingWithOverride.scala
Result:
Scala 2.13 compilation succeeds.
Tests:
- scalafmt --list --mode diff-ref=origin/main: pass
References:
Fixes #1067
---
.../pekko/http/impl/util/StageLoggingWithOverride.scala | 9 ++++-----
.../apache/pekko/http/scaladsl/server/PathMatcher.scala | 17 +++++------------
2 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/util/StageLoggingWithOverride.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/util/StageLoggingWithOverride.scala
index 4ae7807f5..89c21dc9d 100644
--- a/http-core/src/main/scala/org/apache/pekko/http/impl/util/StageLoggingWithOverride.scala
+++ b/http-core/src/main/scala/org/apache/pekko/http/impl/util/StageLoggingWithOverride.scala
@@ -41,11 +41,10 @@ private[pekko] trait StageLoggingWithOverride extends GraphStageLogic {
case null =>
_log =
logOverride match {
- case DefaultNoLogging =>
- {
- implicit val classLogSource: LogSource[Class[?]] = LogSource.fromClass
- pekko.event.Logging(materializer.system, logSource: Class[?])
- }
+ case DefaultNoLogging => {
+ implicit val classLogSource: LogSource[Class[?]] = LogSource.fromClass
+ pekko.event.Logging(materializer.system, logSource: Class[?])
+ }
case x => x
}
case _ =>
diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/PathMatcher.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/PathMatcher.scala
index 63d55ff90..01baec997 100644
--- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/PathMatcher.scala
+++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/PathMatcher.scala
@@ -100,8 +100,7 @@ abstract class PathMatcher[L](implicit val ev: Tuple[L]) extends (Path => PathMa
*/
def repeat(min: Int, max: Int, separator: PathMatcher0 = PathMatchers.Neutral)(
implicit lift: PathMatcher.Lift[L, List]): PathMatcher[lift.Out] = {
- implicit val tupleEv: Tuple[lift.Out] = lift.OutIsTuple
- new PathMatcher[lift.Out]() {
+ new PathMatcher[lift.Out]()(lift.OutIsTuple) {
require(min >= 0, "`min` must be >= 0")
require(max >= min, "`max` must be >= `min`")
@@ -158,12 +157,10 @@ object PathMatcher extends ImplicitPathMatcherConstruction {
/**
* Creates a PathMatcher that always matches, consumes nothing and extracts the given Tuple of values.
*/
- def provide[L](extractions: L)(implicit ev: Tuple[L]): PathMatcher[L] = {
- implicit val tupleL: Tuple[L] = ev
+ def provide[L](extractions: L)(implicit ev: Tuple[L]): PathMatcher[L] =
new PathMatcher[L] {
def apply(path: Path) = Matched(path, extractions)
}
- }
/**
* Creates a PathMatcher that matches and consumes the given path prefix and extracts the given list of extractions.
@@ -171,14 +168,12 @@ object PathMatcher extends ImplicitPathMatcherConstruction {
*/
def apply[L](prefix: Path, extractions: L)(implicit ev: Tuple[L]): PathMatcher[L] =
if (prefix.isEmpty) provide(extractions)
- else {
- implicit val tupleL: Tuple[L] = ev
+ else
new PathMatcher[L] {
def apply(path: Path) =
if (path.startsWith(prefix)) Matched(path.dropChars(prefix.charCount), extractions)
else Unmatched
}
- }
/** Provoke implicit conversions to PathMatcher to be applied */
def apply[L](magnet: PathMatcher[L]): PathMatcher[L] = magnet
@@ -190,15 +185,13 @@ object PathMatcher extends ImplicitPathMatcherConstruction {
}
implicit class EnhancedPathMatcher[L](underlying: PathMatcher[L]) {
- def optional(implicit lift: PathMatcher.Lift[L, Option]): PathMatcher[lift.Out] = {
- implicit val tupleEv: Tuple[lift.Out] = lift.OutIsTuple
- new PathMatcher[lift.Out]() {
+ def optional(implicit lift: PathMatcher.Lift[L, Option]): PathMatcher[lift.Out] =
+ new PathMatcher[lift.Out]()(lift.OutIsTuple) {
def apply(path: Path) = underlying(path) match {
case Matched(rest, extractions) => Matched(rest, lift(extractions))
case Unmatched => Matched(path, lift())
}
}
- }
def ?(implicit lift: PathMatcher.Lift[L, Option]): PathMatcher[lift.Out] = optional(lift)
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org