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 d82138c6964..2b83dec7ee0 100644 --- a/compiler/util-klib/src/org/jetbrains/kotlin/library/SearchPathResolver.kt +++ b/compiler/util-klib/src/org/jetbrains/kotlin/library/SearchPathResolver.kt @@ -54,8 +54,10 @@ abstract class KotlinLibrarySearchPathResolver( (listOf(currentDirHead) + repoRoots + listOf(localHead, distHead, distPlatformHead)).filterNotNull() } + private val files: Set by lazy { searchRoots.flatMap { it.listFilesOrEmpty }.map { it.absolutePath }.toSet() } + private fun found(candidate: File): File? { - fun check(file: File): Boolean = file.exists + fun check(file: File): Boolean = files.contains(file.absolutePath) || file.exists val noSuffix = File(candidate.path.removeSuffixIfPresent(KLIB_FILE_EXTENSION_WITH_DOT)) val withSuffix = File(candidate.path.suffixIfNot(KLIB_FILE_EXTENSION_WITH_DOT)) @@ -292,4 +294,4 @@ class CompilerSingleFileKlibResolveAllowingIrProvidersStrategy( SingleKlibComponentResolver( libraryFile.absolutePath, logger, knownIrProviders ).resolve(libraryFile.absolutePath) -} \ No newline at end of file +} diff --git a/compiler/util-klib/src/org/jetbrains/kotlin/library/impl/KotlinLibraryImpl.kt b/compiler/util-klib/src/org/jetbrains/kotlin/library/impl/KotlinLibraryImpl.kt index cb1f37e905e..ed38e7e9599 100644 --- a/compiler/util-klib/src/org/jetbrains/kotlin/library/impl/KotlinLibraryImpl.kt +++ b/compiler/util-klib/src/org/jetbrains/kotlin/library/impl/KotlinLibraryImpl.kt @@ -28,20 +28,21 @@ open class BaseKotlinLibraryImpl( override val libraryFile get() = access.klib override val libraryName: String by lazy { access.inPlace { it.libraryName } } - override val componentList: List by lazy { - access.inPlace { - it.libDir.listFiles + private val componentListAndHasPre14Manifest by lazy { + access.inPlace { layout -> + val listFiles = layout.libDir.listFiles + listFiles .filter { it.isDirectory } .filter { it.listFiles.map { it.name }.contains(KLIB_MANIFEST_FILE_NAME) } - .map { it.name } + .map { it.name } to listFiles.any { it.absolutePath == layout.pre_1_4_manifest.absolutePath } } } + override val componentList: List get() = componentListAndHasPre14Manifest.first + override fun toString() = "$libraryName[default=$isDefault]" - override val has_pre_1_4_manifest: Boolean by lazy { - access.inPlace { it.pre_1_4_manifest.exists } - } + override val has_pre_1_4_manifest: Boolean get() = componentListAndHasPre14Manifest.second override val manifestProperties: Properties by lazy { access.inPlace { it.manifestFile.loadProperties() }