From 89a8e1cbbd6cbdbb38557310e0153c95d4afbf73 Mon Sep 17 00:00:00 2001 From: "Alexander.Likhachev" Date: Mon, 11 Dec 2023 20:40:29 +0100 Subject: [PATCH] [IC] Revert the paths hashing introduced in 5562c95155f30f7ff3e7bd33cd17a49bcc778890 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `File.hashCode()` behavior is OS-dependent. This can lead to the loss of mapping between a path and its related data in PersistentHashMap — for instance, when a map generated on Microsoft Windows is used on macOS. Notably, this can occur even though both systems use case-insensitive filesystems by default. This commit returns the hashing based on OS-independent path strings ^KT-64016 Verification Pending --- .../kotlin/incremental/storage/FileToPathConverter.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build-common/src/org/jetbrains/kotlin/incremental/storage/FileToPathConverter.kt b/build-common/src/org/jetbrains/kotlin/incremental/storage/FileToPathConverter.kt index bb2eeabf12553..1bff695823a33 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/storage/FileToPathConverter.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/storage/FileToPathConverter.kt @@ -47,9 +47,7 @@ private class FileDescriptor(private val pathConverter: FileToPathConverter) : K // If we use a RelocatableFileToPathConverter instead, the file paths will be normalized first, so we'll get the same hash codes: // [In "/path/to/project1"] File("src/foo.kt").hashCode() = 789 // [In "/path/to/project2"] File("src/foo.kt").hashCode() = 789 - // It's also important to get the hash code using `File.hashCode()` instead of `String.hashCode()` because the hashCode() method - // needs to account for case-insensitive filesystems. - return File(pathConverter.toPath(file)).hashCode() + return pathConverter.toPath(file).hashCode() } override fun isEqual(file1: File, file2: File): Boolean {