[Compatibility] Restore ModuleSourceInfo.getPlatform() for compatibility
This commit is contained in:
@@ -48,6 +48,7 @@ import org.jetbrains.kotlin.platform.idePlatformKind
|
||||
import org.jetbrains.kotlin.resolve.PlatformDependentCompilerServices
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.platform.compat.toOldPlatform
|
||||
import org.jetbrains.kotlin.platform.isCommon
|
||||
import org.jetbrains.kotlin.platform.js.isJs
|
||||
import org.jetbrains.kotlin.platform.jvm.isJvm
|
||||
@@ -154,6 +155,14 @@ interface ModuleSourceInfo : IdeaModuleInfo, TrackableModuleInfo {
|
||||
override val platform: TargetPlatform
|
||||
get() = TargetPlatformDetector.getPlatform(module)
|
||||
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@Deprecated(
|
||||
message = "This accessor is deprecated and will be removed soon, use API from 'org.jetbrains.kotlin.platform.*' packages instead",
|
||||
replaceWith = ReplaceWith("platform"),
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
fun getPlatform(): org.jetbrains.kotlin.resolve.TargetPlatform = platform.toOldPlatform()
|
||||
|
||||
override val compilerServices: PlatformDependentCompilerServices
|
||||
get() = platform.findCompilerServices
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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", "TYPEALIAS_EXPANSION_DEPRECATION_ERROR")
|
||||
|
||||
package org.jetbrains.kotlin.platform.compat
|
||||
|
||||
import org.jetbrains.kotlin.platform.CommonPlatforms
|
||||
import org.jetbrains.kotlin.platform.js.JsPlatform
|
||||
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatform
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.platform.konan.KonanPlatform
|
||||
import org.jetbrains.kotlin.platform.konan.KonanPlatforms
|
||||
|
||||
typealias OldPlatform = org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
typealias NewPlatform = org.jetbrains.kotlin.platform.TargetPlatform
|
||||
|
||||
fun NewPlatform.toOldPlatform(): OldPlatform = when (val single = singleOrNull()) {
|
||||
null -> CommonPlatforms.CompatCommonPlatform
|
||||
is JvmPlatform -> JvmPlatforms.CompatJvmPlatform
|
||||
is JsPlatform -> JsPlatforms.CompatJsPlatform
|
||||
is KonanPlatform -> KonanPlatforms.CompatKonanPlatform
|
||||
else -> error("Unknown platform $single")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user