@@ -94,7 +94,7 @@ private const val URI_PATH_SEPARATOR: String = "/"
9494 * selects the absolute (`/a/b`) versus rootless (`a/b`) form, so a relative reference (`a/b`) and a
9595 * scheme-rootless path (`mailto:a@b`) each round-trip unchanged.
9696 */
97- internal fun ComponentPath.Segments.toUriPathString (): String =
97+ internal fun ComponentPath.Segments.toSegmentsPathString (): String =
9898 when {
9999 segments.isEmpty() -> " "
100100 rooted -> URI_PATH_SEPARATOR + segments.joinToString(URI_PATH_SEPARATOR )
@@ -105,13 +105,14 @@ internal fun ComponentPath.Segments.toUriPathString(): String =
105105 * Encodes any [ComponentPath] back to its RFC 3986 §5.3 string form: an [Opaque][ComponentPath.Opaque] path
106106 * verbatim (no `/` guard, never dot-collapsed), else the [Segments][ComponentPath.Segments] join.
107107 *
108- * The smart-cast `Segments` receiver dispatches to the more specific [toUriPathString] overload, so
109- * this is a dispatch, not a recursion.
108+ * Named distinctly from [toSegmentsPathString] (rather than overloading the same name) so dispatch
109+ * never depends on the caller's static type: a `ComponentPath`-typed receiver always reaches this
110+ * function, which then forwards the smart-cast `Segments` case explicitly.
110111 */
111112internal fun ComponentPath.toUriPathString (): String =
112113 when (this ) {
113114 is ComponentPath .Opaque -> path
114- is ComponentPath .Segments -> toUriPathString ()
115+ is ComponentPath .Segments -> toSegmentsPathString ()
115116 }
116117
117118/* *
@@ -352,10 +353,10 @@ internal data class BuilderPath(
352353 */
353354 fun effectivePath (hasHost : Boolean ): String =
354355 when (rooting) {
355- PathRooting .ROOTED -> ComponentPath .Segments (segments, rooted = true ).toUriPathString ()
356- PathRooting .ROOTLESS -> ComponentPath .Segments (segments, rooted = false ).toUriPathString ()
356+ PathRooting .ROOTED -> ComponentPath .Segments (segments, rooted = true ).toSegmentsPathString ()
357+ PathRooting .ROOTLESS -> ComponentPath .Segments (segments, rooted = false ).toSegmentsPathString ()
357358 PathRooting .DEFERRED -> {
358- val rootless = ComponentPath .Segments (segments, rooted = false ).toUriPathString ()
359+ val rootless = ComponentPath .Segments (segments, rooted = false ).toSegmentsPathString ()
359360 if (hasHost) URI_PATH_SEPARATOR + rootless else rootless
360361 }
361362 }
0 commit comments