[Compatibility] Restore KotlinProjectConfugirator.getTargetPlatform()

Original commit: 716e55d171
This commit is contained in:
Dmitry Savvinov
2019-05-17 13:22:58 +03:00
parent 4c4d6dfd23
commit 9be3d90cb6
@@ -32,6 +32,21 @@ fun NewPlatform.toOldPlatform(): OldPlatform = when (val single = singleOrNull()
else -> error("Unknown platform $single")
}
fun OldPlatform.toNewPlatform(): NewPlatform = when (this) {
is CommonPlatforms.CompatCommonPlatform -> this
is JvmPlatforms.CompatJvmPlatform -> this
is JsPlatforms.CompatJsPlatform -> this
is KonanPlatforms.CompatKonanPlatform -> this
else -> error(
"Can't convert org.jetbrains.kotlin.resolve.TargetPlatform to org.jetbrains.kotlin.platform.TargetPlatform: " +
"non-Compat instance passed\n" +
"toString: $this\n" +
"class: ${this::class}\n" +
"hashCode: ${this.hashCode().toString(16)}"
)
}
fun IdePlatform<*, *>.toNewPlatform(): NewPlatform = when (this) {
is CommonIdePlatformKind.Platform -> CommonPlatforms.defaultCommonPlatform
is JvmIdePlatformKind.Platform -> JvmPlatforms.jvmPlatformByTargetVersion(this.version)