[JS IR] Fix transitive dependency resolve
This commit is contained in:
@@ -52,7 +52,6 @@ import org.jetbrains.kotlin.library.*
|
|||||||
import org.jetbrains.kotlin.library.impl.BuiltInsPlatform
|
import org.jetbrains.kotlin.library.impl.BuiltInsPlatform
|
||||||
import org.jetbrains.kotlin.library.impl.buildKotlinLibrary
|
import org.jetbrains.kotlin.library.impl.buildKotlinLibrary
|
||||||
import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult
|
import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult
|
||||||
import org.jetbrains.kotlin.library.resolver.TopologicalLibraryOrder
|
|
||||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||||
import org.jetbrains.kotlin.progress.IncrementalNextRoundException
|
import org.jetbrains.kotlin.progress.IncrementalNextRoundException
|
||||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
|
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
|
||||||
@@ -380,15 +379,10 @@ private class ModulesStructure(
|
|||||||
private val friendDependencies: List<KotlinLibrary>
|
private val friendDependencies: List<KotlinLibrary>
|
||||||
) {
|
) {
|
||||||
val moduleDependencies: Map<KotlinLibrary, List<KotlinLibrary>> = run {
|
val moduleDependencies: Map<KotlinLibrary, List<KotlinLibrary>> = run {
|
||||||
val result = mutableMapOf<KotlinLibrary, List<KotlinLibrary>>()
|
val transitives = allDependencies.getFullResolvedList()
|
||||||
|
transitives.associate { klib ->
|
||||||
allDependencies.forEach { klib, _ ->
|
klib.library to klib.resolvedDependencies.map { d -> d.library }
|
||||||
val dependencies = allDependencies.filterRoots {
|
}.toMap()
|
||||||
it.library == klib
|
|
||||||
}.getFullList(TopologicalLibraryOrder)
|
|
||||||
result.put(klib, dependencies.minus(klib))
|
|
||||||
}
|
|
||||||
result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val builtInsDep = allDependencies.getFullList().find { it.isBuiltIns }
|
val builtInsDep = allDependencies.getFullList().find { it.isBuiltIns }
|
||||||
|
|||||||
+2
-1
@@ -23,7 +23,8 @@ interface KotlinLibraryResolveResult {
|
|||||||
|
|
||||||
fun filterRoots(predicate: (KotlinResolvedLibrary) -> Boolean): KotlinLibraryResolveResult
|
fun filterRoots(predicate: (KotlinResolvedLibrary) -> Boolean): KotlinLibraryResolveResult
|
||||||
|
|
||||||
fun getFullList(order: LibraryOrder? = null): List<KotlinLibrary>
|
fun getFullList(order: LibraryOrder? = null): List<KotlinLibrary> = getFullResolvedList(order).map { it.library }
|
||||||
|
fun getFullResolvedList(order: LibraryOrder? = null): List<KotlinResolvedLibrary>
|
||||||
|
|
||||||
fun forEach(action: (KotlinLibrary, PackageAccessHandler) -> Unit)
|
fun forEach(action: (KotlinLibrary, PackageAccessHandler) -> Unit)
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-13
@@ -143,30 +143,29 @@ class KotlinLibraryResolverResultImpl(
|
|||||||
private val roots: List<KotlinResolvedLibrary>
|
private val roots: List<KotlinResolvedLibrary>
|
||||||
): KotlinLibraryResolveResult {
|
): KotlinLibraryResolveResult {
|
||||||
|
|
||||||
private val all: List<KotlinResolvedLibrary> by lazy {
|
private val all: List<KotlinResolvedLibrary>
|
||||||
val result = mutableSetOf<KotlinResolvedLibrary>().also { it.addAll(roots) }
|
by lazy {
|
||||||
|
val result = mutableSetOf<KotlinResolvedLibrary>().also { it.addAll(roots) }
|
||||||
|
|
||||||
var newDependencies = result.toList()
|
var newDependencies = result.toList()
|
||||||
do {
|
do {
|
||||||
newDependencies = newDependencies
|
newDependencies = newDependencies
|
||||||
.map { it -> it.resolvedDependencies }.flatten()
|
.map { it.resolvedDependencies }.flatten()
|
||||||
.filter { it !in result }
|
.filter { it !in result }
|
||||||
result.addAll(newDependencies)
|
result.addAll(newDependencies)
|
||||||
} while (newDependencies.isNotEmpty())
|
} while (newDependencies.isNotEmpty())
|
||||||
|
|
||||||
result.toList()
|
result.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun filterRoots(predicate: (KotlinResolvedLibrary) -> Boolean) =
|
override fun filterRoots(predicate: (KotlinResolvedLibrary) -> Boolean) =
|
||||||
KotlinLibraryResolverResultImpl(roots.filter(predicate))
|
KotlinLibraryResolverResultImpl(roots.filter(predicate))
|
||||||
|
|
||||||
override fun getFullList(order: LibraryOrder?) = (order?.invoke(all) ?: all).asPlain()
|
override fun getFullResolvedList(order: LibraryOrder?) = (order?.invoke(all) ?: all)
|
||||||
|
|
||||||
override fun forEach(action: (KotlinLibrary, PackageAccessHandler) -> Unit) {
|
override fun forEach(action: (KotlinLibrary, PackageAccessHandler) -> Unit) {
|
||||||
all.forEach { action(it.library, it) }
|
all.forEach { action(it.library, it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun List<KotlinResolvedLibrary>.asPlain() = map { it.library }
|
|
||||||
|
|
||||||
override fun toString() = "roots=$roots, all=$all"
|
override fun toString() = "roots=$roots, all=$all"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user