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.TargetPlatform
import org.jetbrains.kotlin.platform.isCommon import org.jetbrains.kotlin.platform.isCommon
import org.jetbrains.kotlin.platform.js.JsPlatform 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.JvmPlatform
import org.jetbrains.kotlin.platform.jvm.isJvm
import org.jetbrains.kotlin.platform.konan.NativePlatform import org.jetbrains.kotlin.platform.konan.NativePlatform
import org.jetbrains.kotlin.platform.konan.isNative
import org.jetbrains.kotlin.resolve.* import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
import org.jetbrains.kotlin.resolve.konan.platform.NativePlatformAnalyzerServices import org.jetbrains.kotlin.resolve.konan.platform.NativePlatformAnalyzerServices
import java.lang.IllegalStateException import java.lang.IllegalStateException
fun TargetPlatform.findAnalyzerServices(project: Project): PlatformDependentAnalyzerServices = when { fun TargetPlatform.findAnalyzerServices(project: Project): PlatformDependentAnalyzerServices = when {
isCommon() && project.useCompositeAnalysis -> CompositeAnalyzerServices(componentPlatforms.map { it.findAnalyzerServices() }) isCommon() -> {
isCommon() && !project.useCompositeAnalysis -> CommonPlatformAnalyzerServices if (project.useCompositeAnalysis)
else -> single().findAnalyzerServices() CompositeAnalyzerServices(componentPlatforms.map { it.findAnalyzerServices() })
else
CommonPlatformAnalyzerServices
}
isJvm() -> JvmPlatformAnalyzerServices
isJs() -> JsPlatformAnalyzerServices
isNative() -> NativePlatformAnalyzerServices
else -> throw IllegalStateException("Unknown platform $this")
} }
fun SimplePlatform.findAnalyzerServices(): PlatformDependentAnalyzerServices { fun SimplePlatform.findAnalyzerServices(): PlatformDependentAnalyzerServices = when (this) {
return when (this) { is JvmPlatform -> JvmPlatformAnalyzerServices
is JvmPlatform -> JvmPlatformAnalyzerServices is JsPlatform -> JsPlatformAnalyzerServices
is JsPlatform -> JsPlatformAnalyzerServices is NativePlatform -> NativePlatformAnalyzerServices
is NativePlatform -> NativePlatformAnalyzerServices else -> throw IllegalStateException("Unknown platform $this")
else -> throw IllegalStateException("Unknown platform $this") }
}
}