From bca2342dfc5cd7f2dcf33285905decdff6cb2a3d Mon Sep 17 00:00:00 2001 From: Dmitry Savvinov Date: Tue, 9 Apr 2019 12:00:26 +0300 Subject: [PATCH] [Misc] Get rid of IdePlatformKind.IDE_KINDS_BY_COMPILER_PLATFORM It works incorrectly for cases of non-trivial common platforms (works fine for 'JVM/JS/Native', but doesn't work for 'JVM/JS') Original commit: d458821565884ed26dfb0e4cb4746c2e3297f9dc --- .../kotlin/platform/IdePlatformKind.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/jps/jps-common/src/org/jetbrains/kotlin/platform/IdePlatformKind.kt b/jps/jps-common/src/org/jetbrains/kotlin/platform/IdePlatformKind.kt index 36e678fa59b..8e222c16a07 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/platform/IdePlatformKind.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/platform/IdePlatformKind.kt @@ -4,6 +4,7 @@ */ @file:JvmName("IdePlatformKindUtil") + package org.jetbrains.kotlin.platform import org.jetbrains.kotlin.extensions.ApplicationExtensionDescriptor @@ -13,6 +14,10 @@ import org.jetbrains.kotlin.platform.impl.CommonIdePlatformKind import org.jetbrains.kotlin.platform.impl.JsIdePlatformKind import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind import org.jetbrains.kotlin.platform.impl.NativeIdePlatformKind +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.platform.js.JsPlatform +import org.jetbrains.kotlin.platform.jvm.JvmPlatform +import org.jetbrains.kotlin.platform.konan.KonanPlatform import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult abstract class IdePlatformKind> { @@ -64,12 +69,6 @@ abstract class IdePlatformKind> { val All_PLATFORMS by lazy { ALL_KINDS.flatMap { it.platforms } } - val IDE_PLATFORMS_BY_COMPILER_PLATFORMS by lazy { - ALL_KINDS.flatMap { idePlatformKind -> - idePlatformKind.platforms.map { compilerPlatform -> compilerPlatform to idePlatformKind } - }.toMap() - } - fun platformByCompilerArguments(arguments: Args): TargetPlatform? = ALL_KINDS.firstNotNullResult { it.platformByCompilerArguments(arguments) } @@ -77,4 +76,10 @@ abstract class IdePlatformKind> { } val TargetPlatform.idePlatformKind: IdePlatformKind<*> - get() = IdePlatformKind.IDE_PLATFORMS_BY_COMPILER_PLATFORMS[this] ?: error("Unknown platform $this") \ No newline at end of file + get() = when (val single = singleOrNull()) { + null -> CommonIdePlatformKind + is JvmPlatform -> JvmIdePlatformKind + is JsPlatform -> JsIdePlatformKind + is KonanPlatform -> NativeIdePlatformKind + else -> error("Unknown platform $single") + }