[K/N] Fix general case of KT-49827
When loading default libraries, the code assumed that all subdirectories of <kotlin native home>/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 <troels@google.com>
This commit is contained in:
committed by
Space
parent
ef499fedbb
commit
e520fb712b
@@ -187,10 +187,11 @@ abstract class KotlinLibrarySearchPathResolver<L : KotlinLibrary>(
|
||||
val defaultRoots: List<File>
|
||||
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) }
|
||||
|
||||
Reference in New Issue
Block a user