[Compatibility] Restore old TargetPlatform and subtypes for compatibility
This commit is contained in:
@@ -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
|
||||||
import org.jetbrains.kotlin.platform.konan.KonanPlatforms.defaultKonanPlatform
|
import org.jetbrains.kotlin.platform.konan.KonanPlatforms.defaultKonanPlatform
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION_ERROR")
|
||||||
object CommonPlatforms {
|
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(
|
setOf(
|
||||||
defaultJvmPlatform.single(),
|
defaultJvmPlatform.single(),
|
||||||
defaultJsPlatform.single(),
|
defaultJsPlatform.single(),
|
||||||
defaultKonanPlatform.single()
|
defaultKonanPlatform.single()
|
||||||
)
|
)
|
||||||
)
|
), org.jetbrains.kotlin.analyzer.common.CommonPlatform
|
||||||
|
|
||||||
|
val defaultCommonPlatform: TargetPlatform
|
||||||
|
get() = CompatCommonPlatform
|
||||||
|
|
||||||
val allSimplePlatforms: List<TargetPlatform>
|
val allSimplePlatforms: List<TargetPlatform>
|
||||||
get() = sequence {
|
get() = sequence {
|
||||||
|
|||||||
@@ -14,8 +14,20 @@ abstract class KonanPlatform : SimplePlatform("Native") {
|
|||||||
get() = "Kotlin/Native "
|
get() = "Kotlin/Native "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION_ERROR")
|
||||||
object KonanPlatforms {
|
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)
|
val allKonanPlatforms: List<TargetPlatform> = listOf(defaultKonanPlatform)
|
||||||
}
|
}
|
||||||
|
|||||||
+27
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.resolve
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
message = "This class is deprecated and will be removed soon, use API from 'org.jetbrains.kotlin.platform.*' packages instead",
|
||||||
|
replaceWith = ReplaceWith("TargetPlatform", "org.jetbrains.kotlin.platform.TargetPlatform"),
|
||||||
|
level = DeprecationLevel.ERROR
|
||||||
|
)
|
||||||
|
interface TargetPlatform {
|
||||||
|
val platformName: String
|
||||||
|
}
|
||||||
@@ -16,11 +16,26 @@ abstract class JvmPlatform : SimplePlatform("JVM") {
|
|||||||
get() = "JVM "
|
get() = "JVM "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION_ERROR")
|
||||||
object JvmPlatforms {
|
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> =
|
private val jvmTargetToJdkPlatform: Map<JvmTarget, TargetPlatform> =
|
||||||
JvmTarget.values().map { it to JdkPlatform(it).toTargetPlatform() }.toMap()
|
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 jvm16: TargetPlatform = jvmTargetToJdkPlatform[JvmTarget.JVM_1_6]!!
|
||||||
val jvm18: TargetPlatform = jvmTargetToJdkPlatform[JvmTarget.JVM_1_8]!!
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,12 +18,26 @@ package org.jetbrains.kotlin.platform
|
|||||||
* it still can be applicable for [TargetPlatform]s with [componentPlatforms] > 1, e.g. when it consists
|
* it still can be applicable for [TargetPlatform]s with [componentPlatforms] > 1, e.g. when it consists
|
||||||
* of two version of JDK, JDK and Android, several versions of Android API, etc.
|
* of two version of JDK, JDK and Android, several versions of Android API, etc.
|
||||||
*/
|
*/
|
||||||
data class TargetPlatform(val componentPlatforms: Set<SimplePlatform>) : Collection<SimplePlatform> by componentPlatforms {
|
open class TargetPlatform(val componentPlatforms: Set<SimplePlatform>) : Collection<SimplePlatform> by componentPlatforms {
|
||||||
init {
|
init {
|
||||||
if (componentPlatforms.isEmpty()) throw IllegalArgumentException("Don't instantiate TargetPlatform with empty set of platforms")
|
if (componentPlatforms.isEmpty()) throw IllegalArgumentException("Don't instantiate TargetPlatform with empty set of platforms")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String = presentableDescription
|
override fun toString(): String = presentableDescription
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
|
||||||
|
if (other !is TargetPlatform) return false
|
||||||
|
|
||||||
|
if (componentPlatforms != other.componentPlatforms) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
return componentPlatforms.hashCode()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ object JvmIdePlatformKind : IdePlatformKind<JvmIdePlatformKind>() {
|
|||||||
return K2JVMCompilerArguments()
|
return K2JVMCompilerArguments()
|
||||||
}
|
}
|
||||||
|
|
||||||
override val platforms = JvmTarget.values().map { ver -> JvmPlatforms.jvmPlatformByTargetVersion(ver) }
|
override val platforms: List<TargetPlatform> = JvmTarget.values().map { ver -> JvmPlatforms.jvmPlatformByTargetVersion(ver) } + listOf(JvmPlatforms.defaultJvmPlatform)
|
||||||
override val defaultPlatform get() = JvmPlatforms.defaultJvmPlatform
|
override val defaultPlatform get() = JvmPlatforms.defaultJvmPlatform
|
||||||
|
|
||||||
override val argumentsClass get() = K2JVMCompilerArguments::class.java
|
override val argumentsClass get() = K2JVMCompilerArguments::class.java
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("DEPRECATION_ERROR")
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.js.resolve
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
||||||
|
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("JsPlatforms.defaultJsPlatform", "org.jetbrains.kotlin.platform.js.JsPlatforms"),
|
||||||
|
level = DeprecationLevel.ERROR
|
||||||
|
)
|
||||||
|
interface JsPlatform : TargetPlatform {
|
||||||
|
@JvmDefault
|
||||||
|
override val platformName: String
|
||||||
|
get() = "JS"
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmField
|
||||||
|
val INSTANCE: JsPlatform = JsPlatforms.CompatJsPlatform
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,8 +14,20 @@ abstract class JsPlatform : SimplePlatform("JS") {
|
|||||||
get() = "JavaScript "
|
get() = "JavaScript "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION_ERROR")
|
||||||
object JsPlatforms {
|
object JsPlatforms {
|
||||||
val defaultJsPlatform: TargetPlatform = object : JsPlatform() {}.toTargetPlatform()
|
private object DefaultSimpleJsPlatform : JsPlatform()
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
message = "Should be accessed only by compatibility layer, other clients should use 'defaultJsPlatform'",
|
||||||
|
level = DeprecationLevel.ERROR
|
||||||
|
)
|
||||||
|
object CompatJsPlatform : TargetPlatform(setOf(DefaultSimpleJsPlatform)),
|
||||||
|
// Needed for backward compatibility, because old code uses INSTANCEOF checks instead of calling extensions
|
||||||
|
org.jetbrains.kotlin.js.resolve.JsPlatform {}
|
||||||
|
|
||||||
|
val defaultJsPlatform: TargetPlatform
|
||||||
|
get() = CompatJsPlatform
|
||||||
|
|
||||||
val allJsPlatforms: List<TargetPlatform> = listOf(defaultJsPlatform)
|
val allJsPlatforms: List<TargetPlatform> = listOf(defaultJsPlatform)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user