Imitate old comparison behaviour when collecting dependencies
This is needed, because previously such code were not distinguishing between different flavours of JVM or Common. Now we do, and, for example, JdkPlatform(1.6) != JdkPlatform(1.8), which causes such dependencies to be erroneously dropped
This commit is contained in:
@@ -48,6 +48,10 @@ import org.jetbrains.kotlin.platform.idePlatformKind
|
||||
import org.jetbrains.kotlin.resolve.PlatformDependentCompilerServices
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.platform.isCommon
|
||||
import org.jetbrains.kotlin.platform.js.isJs
|
||||
import org.jetbrains.kotlin.platform.jvm.isJvm
|
||||
import org.jetbrains.kotlin.platform.konan.isNative
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformCompilerServices
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.util.*
|
||||
@@ -115,6 +119,13 @@ private fun ideaModelDependencies(
|
||||
forProduction: Boolean,
|
||||
platform: TargetPlatform
|
||||
): List<IdeaModuleInfo> {
|
||||
fun TargetPlatform.canDependOn(other: TargetPlatform): Boolean {
|
||||
return this.isJvm() && other.isJvm() ||
|
||||
this.isJs() && other.isJs() ||
|
||||
this.isNative() && other.isNative() ||
|
||||
this.isCommon() && other.isCommon()
|
||||
}
|
||||
|
||||
//NOTE: lib dependencies can be processed several times during recursive traversal
|
||||
val result = LinkedHashSet<IdeaModuleInfo>()
|
||||
val dependencyEnumerator = ModuleRootManager.getInstance(module).orderEntries().compileOnly().recursively().exportedOnly()
|
||||
@@ -127,7 +138,7 @@ private fun ideaModelDependencies(
|
||||
}
|
||||
true
|
||||
}
|
||||
return result.filterNot { it is LibraryInfo && it.platform != platform }
|
||||
return result.filterNot { it is LibraryInfo && !platform.canDependOn(it.platform) }
|
||||
}
|
||||
|
||||
interface ModuleSourceInfo : IdeaModuleInfo, TrackableModuleInfo {
|
||||
|
||||
Reference in New Issue
Block a user