From e520fb712b9bf02391c33eeb287854928fee4ef4 Mon Sep 17 00:00:00 2001 From: Troels Bjerre Lund Date: Thu, 23 Jun 2022 10:12:38 +0000 Subject: [PATCH] [K/N] Fix general case of KT-49827 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When loading default libraries, the code assumed that all subdirectories of /klib/*/ corresponded to valid libraries. The bug report only considers the case of .DS_STORE, which is generated by Finder on MacOS, but this case has already been accounted for in the code. The fix filters out all subdirectories that are not stdlib and don’t have the “org.jetbrains.kotlin” prefix. Co-authored-by: Troels Lund --- .../src/org/jetbrains/kotlin/library/SearchPathResolver.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/util-klib/src/org/jetbrains/kotlin/library/SearchPathResolver.kt b/compiler/util-klib/src/org/jetbrains/kotlin/library/SearchPathResolver.kt index b7834d49e63..b0929a08aac 100644 --- a/compiler/util-klib/src/org/jetbrains/kotlin/library/SearchPathResolver.kt +++ b/compiler/util-klib/src/org/jetbrains/kotlin/library/SearchPathResolver.kt @@ -187,10 +187,11 @@ abstract class KotlinLibrarySearchPathResolver( val defaultRoots: List get() = listOfNotNull(distHead, distPlatformHead).filter { it.exists } - private fun getDefaultLibrariesFromDir(directory: File) = + private fun getDefaultLibrariesFromDir(directory: File, prefix: String = "org.jetbrains.kotlin") = if (directory.exists) { directory.listFiles .asSequence() + .filter { it.name.startsWith(prefix) } .filterNot { it.name.startsWith('.') } .filterNot { it.name.removeSuffixIfPresent(KLIB_FILE_EXTENSION_WITH_DOT) == KOTLIN_STDLIB_NAME } .map { UnresolvedLibrary(it.absolutePath, null) }