HMPP: Fix detection of PlatformDependentAnalyzerServices for TargetPlatform

This commit is contained in:
Dmitriy Dolovov
2020-04-06 21:32:41 +07:00
parent 76b0e7994b
commit e3e1c2cb3b
@@ -13,24 +13,32 @@ import org.jetbrains.kotlin.platform.SimplePlatform
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.isCommon
import org.jetbrains.kotlin.platform.js.JsPlatform
import org.jetbrains.kotlin.platform.js.isJs
import org.jetbrains.kotlin.platform.jvm.JvmPlatform
import org.jetbrains.kotlin.platform.jvm.isJvm
import org.jetbrains.kotlin.platform.konan.NativePlatform
import org.jetbrains.kotlin.platform.konan.isNative
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
import org.jetbrains.kotlin.resolve.konan.platform.NativePlatformAnalyzerServices
import java.lang.IllegalStateException
fun TargetPlatform.findAnalyzerServices(project: Project): PlatformDependentAnalyzerServices = when {
isCommon() && project.useCompositeAnalysis -> CompositeAnalyzerServices(componentPlatforms.map { it.findAnalyzerServices() })
isCommon() && !project.useCompositeAnalysis -> CommonPlatformAnalyzerServices
else -> single().findAnalyzerServices()
isCommon() -> {
if (project.useCompositeAnalysis)
CompositeAnalyzerServices(componentPlatforms.map { it.findAnalyzerServices() })
else
CommonPlatformAnalyzerServices
}
isJvm() -> JvmPlatformAnalyzerServices
isJs() -> JsPlatformAnalyzerServices
isNative() -> NativePlatformAnalyzerServices
else -> throw IllegalStateException("Unknown platform $this")
}
fun SimplePlatform.findAnalyzerServices(): PlatformDependentAnalyzerServices {
return when (this) {
is JvmPlatform -> JvmPlatformAnalyzerServices
is JsPlatform -> JsPlatformAnalyzerServices
is NativePlatform -> NativePlatformAnalyzerServices
else -> throw IllegalStateException("Unknown platform $this")
}
}
fun SimplePlatform.findAnalyzerServices(): PlatformDependentAnalyzerServices = when (this) {
is JvmPlatform -> JvmPlatformAnalyzerServices
is JsPlatform -> JsPlatformAnalyzerServices
is NativePlatform -> NativePlatformAnalyzerServices
else -> throw IllegalStateException("Unknown platform $this")
}