Skip to content

Commit 23be6a9

Browse files
committed
Workaround for KT-22520
1 parent 1d8e270 commit 23be6a9

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

core/common/src/files/Paths.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,14 @@ public expect val SystemPathSeparator: Char
7474
*/
7575
public expect fun Path(path: String): Path
7676

77+
// Workaround for https://youtrack.jetbrains.com/issue/KT-22520
78+
internal expect fun PathCtorInternal(path: String): Path
79+
7780
/**
7881
* Returns Path for the given [base] path concatenated with [parts] using [SystemPathSeparator].
7982
*/
8083
public fun Path(base: String, vararg parts: String): Path {
81-
return Path(buildString {
84+
return PathCtorInternal(buildString {
8285
append(base)
8386
parts.forEach {
8487
if (isNotEmpty() && !endsWith(SystemPathSeparator)) {

core/jvm/src/files/PathsJvm.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public actual val SystemPathSeparator: Char = File.separatorChar
4141

4242
public actual fun Path(path: String): Path = Path(File(path))
4343

44+
internal actual fun PathCtorInternal(path: String): Path = Path(path)
45+
4446
// Function only exists to provide binary compatibility with the earlier releases
4547
@JvmName("source")
4648
@PublishedApi

core/native/src/files/PathsNative.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ internal expect fun isAbsoluteImpl(path: String): Boolean
6464

6565
public actual fun Path(path: String): Path = Path(path, null)
6666

67+
internal actual fun PathCtorInternal(path: String): Path = Path(path)
68+
6769
internal class FileSource(
6870
private val file: CPointer<FILE>
6971
) : RawSource {

core/nodeFilesystemShared/src/files/PathsNodeJs.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public actual fun Path(path: String): Path {
7777
return Path(path, null)
7878
}
7979

80+
internal actual fun PathCtorInternal(path: String): Path = Path(path)
81+
8082
internal class FileSource(private val path: Path) : RawSource {
8183
private var buffer: kotlinx.io.node.buffer.Buffer? = null
8284
private var closed = false

core/wasmWasi/src/files/PathsWasm.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,5 @@ public actual class Path internal constructor(rawPath: String, @Suppress("UNUSED
5555
public actual val SystemPathSeparator: Char = UnixPathSeparator
5656

5757
public actual fun Path(path: String): Path = Path(path, null as Any?)
58+
59+
internal actual fun PathCtorInternal(path: String): Path = Path(path)

0 commit comments

Comments
 (0)