[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
@@ -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.analyzer.common
import org.jetbrains.kotlin.platform.CommonPlatforms
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("CommonPlatforms.defaultCommonPlatform", "org.jetbrains.kotlin.platform.CommonPlatforms"),
level = DeprecationLevel.ERROR
)
interface CommonPlatform : TargetPlatform {
@JvmDefault
override val platformName: String
get() = "Default"
companion object {
@JvmField
val INSTANCE: CommonPlatform = CommonPlatforms.CompatCommonPlatform
}
}
@@ -13,15 +13,23 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatforms.jvm18
import org.jetbrains.kotlin.platform.konan.KonanPlatforms
import org.jetbrains.kotlin.platform.konan.KonanPlatforms.defaultKonanPlatform
@Suppress("DEPRECATION_ERROR")
object CommonPlatforms {
val defaultCommonPlatform: TargetPlatform = TargetPlatform(
@Deprecated(
message = "Should be accessed only by compatibility layer, other clients should use 'defaultJvmPlatform'",
level = DeprecationLevel.ERROR
)
object CompatCommonPlatform : TargetPlatform(
setOf(
defaultJvmPlatform.single(),
defaultJsPlatform.single(),
defaultKonanPlatform.single()
)
)
), org.jetbrains.kotlin.analyzer.common.CommonPlatform
val defaultCommonPlatform: TargetPlatform
get() = CompatCommonPlatform
val allSimplePlatforms: List<TargetPlatform>
get() = sequence {
@@ -14,8 +14,20 @@ abstract class KonanPlatform : SimplePlatform("Native") {
get() = "Kotlin/Native "
}
@Suppress("DEPRECATION_ERROR")
object KonanPlatforms {
val defaultKonanPlatform: TargetPlatform = object : KonanPlatform() {}.toTargetPlatform()
private object DefaultSimpleKonanPlatform : KonanPlatform()
@Deprecated(
message = "Should be accessed only by compatibility layer, other clients should use 'defaultKonanPlatform'",
level = DeprecationLevel.ERROR
)
object CompatKonanPlatform : TargetPlatform(setOf(DefaultSimpleKonanPlatform)),
// Needed for backward compatibility, because old code uses INSTANCEOF checks instead of calling extensions
org.jetbrains.kotlin.resolve.konan.platform.KonanPlatform {}
val defaultKonanPlatform: TargetPlatform
get() = CompatKonanPlatform
val allKonanPlatforms: List<TargetPlatform> = listOf(defaultKonanPlatform)
}
@@ -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.konan.platform
import org.jetbrains.kotlin.platform.konan.KonanPlatforms
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("KonanPlatforms.defaultKonanPlatform", "org.jetbrains.kotlin.platform.konan.KonanPlatforms"),
level = DeprecationLevel.ERROR
)
interface KonanPlatform : TargetPlatform {
@JvmDefault
override val platformName: String
get() = "Native"
companion object {
@JvmField
val INSTANCE: KonanPlatform = KonanPlatforms.CompatKonanPlatform
}
}