[Compatibility] Restore old TargetPlatform and subtypes for compatibility

This commit is contained in:
Dmitry Savvinov
2019-05-14 12:52:22 +03:00
parent bbe7a9790e
commit 2caa1c3dd6
11 changed files with 202 additions and 7 deletions
@@ -16,11 +16,26 @@ abstract class JvmPlatform : SimplePlatform("JVM") {
get() = "JVM "
}
@Suppress("DEPRECATION_ERROR")
object JvmPlatforms {
private object UnspecifiedSimpleJvmPlatform : JvmPlatform() {
override val targetPlatformVersion: TargetPlatformVersion
get() = JvmTarget.JVM_1_6
}
@Deprecated(
message = "Should be accessed only by compatibility layer, other clients should use 'defaultJvmPlatform'",
level = DeprecationLevel.ERROR
)
object CompatJvmPlatform : TargetPlatform(setOf(UnspecifiedSimpleJvmPlatform)),
// Needed for backward compatibility, because old code uses INSTANCEOF checks instead of calling extensions
org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform {}
private val jvmTargetToJdkPlatform: Map<JvmTarget, TargetPlatform> =
JvmTarget.values().map { it to JdkPlatform(it).toTargetPlatform() }.toMap()
val defaultJvmPlatform: TargetPlatform = jvmTargetToJdkPlatform[JvmTarget.DEFAULT]!!
val defaultJvmPlatform: TargetPlatform
get() = CompatJvmPlatform
val jvm16: TargetPlatform = jvmTargetToJdkPlatform[JvmTarget.JVM_1_6]!!
val jvm18: TargetPlatform = jvmTargetToJdkPlatform[JvmTarget.JVM_1_8]!!
@@ -0,0 +1,27 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("DEPRECATION_ERROR")
package org.jetbrains.kotlin.resolve.jvm.platform
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.resolve.TargetPlatform
@Deprecated(
message = "This class is deprecated and will be removed soon, use API from 'org.jetbrains.kotlin.platform.*' packages instead",
replaceWith = ReplaceWith("JvmPlatforms.defaultJvmPlatform", "org.jetbrains.kotlin.platform.jvm.JvmPlatforms"),
level = DeprecationLevel.ERROR
)
interface JvmPlatform : TargetPlatform {
@JvmDefault
override val platformName: String
get() = "JVM"
companion object {
@JvmField
val INSTANCE: JvmPlatform = JvmPlatforms.CompatJvmPlatform
}
}