diff --git a/compiler/config.jvm/src/org/jetbrains/kotlin/platform/jvm/JvmPlatform.kt b/compiler/config.jvm/src/org/jetbrains/kotlin/platform/jvm/JvmPlatform.kt index 659bb7681c1..68ff43b357b 100644 --- a/compiler/config.jvm/src/org/jetbrains/kotlin/platform/jvm/JvmPlatform.kt +++ b/compiler/config.jvm/src/org/jetbrains/kotlin/platform/jvm/JvmPlatform.kt @@ -61,14 +61,16 @@ class JdkPlatform(val targetVersion: JvmTarget) : JvmPlatform() { get() = targetVersion // TODO(dsavvinov): temporarily conservative measure; make JdkPlatform data class later - // Explanation: previously we had only one JvmPlatform, and all 'TargetPlatform's had an - // equality (actually, identity, because each platform had only one instance). This lead - // to common pattern of putting them in map (e.g., see KotlinCacheServiceImpl.globalFacadesPerPlatformAndSdk). - // - // If we start distinguishing JvmPlatforms with different JvmTarget right now, it may accidentally - // break some clients (in particular, we'll create global facade for *each* JvmTarget, which is a bad idea) + // Explanation: previously we had only one JvmPlatform, and all 'TargetPlatform's had an + // equality (actually, identity, because each platform had only one instance). This lead + // to common pattern of putting them in map (e.g., see KotlinCacheServiceImpl.globalFacadesPerPlatformAndSdk). + // . + // If we start distinguishing JvmPlatforms with different JvmTarget right now, it may accidentally + // break some clients (in particular, we'll create global facade for *each* JvmTarget, which is a bad idea) override fun equals(other: Any?): Boolean = other is JdkPlatform override fun hashCode(): Int = JdkPlatform::class.hashCode() } -fun TargetPlatform?.isJvm(): Boolean = this?.singleOrNull() is JvmPlatform \ No newline at end of file +// TODO: temporarily conservative implementation; use the same approach as for TargetPlatform?.isNative() +// when JdkPlatform becomes a data class +fun TargetPlatform?.isJvm(): Boolean = this?.singleOrNull() is JvmPlatform diff --git a/idea/idea-jps-common/src/org/jetbrains/kotlin/platform/impl/JsIdePlatformKind.kt b/idea/idea-jps-common/src/org/jetbrains/kotlin/platform/impl/JsIdePlatformKind.kt index 1e73d24561c..6b145c67ceb 100644 --- a/idea/idea-jps-common/src/org/jetbrains/kotlin/platform/impl/JsIdePlatformKind.kt +++ b/idea/idea-jps-common/src/org/jetbrains/kotlin/platform/impl/JsIdePlatformKind.kt @@ -15,9 +15,10 @@ import org.jetbrains.kotlin.platform.IdePlatformKind import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.platform.TargetPlatformVersion import org.jetbrains.kotlin.platform.js.JsPlatforms +import org.jetbrains.kotlin.platform.js.isJs object JsIdePlatformKind : IdePlatformKind() { - override fun supportsTargetPlatform(platform: TargetPlatform): Boolean = platforms.contains(platform) + override fun supportsTargetPlatform(platform: TargetPlatform): Boolean = platform.isJs() override fun platformByCompilerArguments(arguments: CommonCompilerArguments): TargetPlatform? { return if (arguments is K2JSCompilerArguments) diff --git a/idea/idea-jps-common/src/org/jetbrains/kotlin/platform/impl/JvmIdePlatformKind.kt b/idea/idea-jps-common/src/org/jetbrains/kotlin/platform/impl/JvmIdePlatformKind.kt index a0ab9b1af92..125b8313cab 100644 --- a/idea/idea-jps-common/src/org/jetbrains/kotlin/platform/impl/JvmIdePlatformKind.kt +++ b/idea/idea-jps-common/src/org/jetbrains/kotlin/platform/impl/JvmIdePlatformKind.kt @@ -16,9 +16,10 @@ import org.jetbrains.kotlin.platform.IdePlatform import org.jetbrains.kotlin.platform.IdePlatformKind import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.platform.jvm.JvmPlatforms +import org.jetbrains.kotlin.platform.jvm.isJvm object JvmIdePlatformKind : IdePlatformKind() { - override fun supportsTargetPlatform(platform: TargetPlatform): Boolean = platforms.contains(platform) + override fun supportsTargetPlatform(platform: TargetPlatform): Boolean = platform.isJvm() override fun platformByCompilerArguments(arguments: CommonCompilerArguments): TargetPlatform? { if (arguments !is K2JVMCompilerArguments) return null diff --git a/js/js.config/src/org/jetbrains/kotlin/platform/js/JsPlatform.kt b/js/js.config/src/org/jetbrains/kotlin/platform/js/JsPlatform.kt index 58d722b7fb6..a43f7ceefb3 100644 --- a/js/js.config/src/org/jetbrains/kotlin/platform/js/JsPlatform.kt +++ b/js/js.config/src/org/jetbrains/kotlin/platform/js/JsPlatform.kt @@ -34,4 +34,6 @@ object JsPlatforms { val allJsPlatforms: List = listOf(defaultJsPlatform) } +// TODO: temporarily conservative implementation; use the same approach as for TargetPlatform?.isNative() +// when JsPlatform will become parameterized with "JS target" fun TargetPlatform?.isJs(): Boolean = this?.singleOrNull() is JsPlatform