Return the default value if an illegal argument is passed..
..to the TargetPlatform during the import process. #KTIJ-27718 Fixed Merge-request: KT-MR-13072 Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
4964ee12a9
commit
079343c093
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.platform.impl
|
package org.jetbrains.kotlin.platform.impl
|
||||||
|
|
||||||
import com.intellij.util.text.VersionComparatorUtil
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||||
import org.jetbrains.kotlin.config.JvmTarget
|
import org.jetbrains.kotlin.config.JvmTarget
|
||||||
@@ -21,15 +20,15 @@ import org.jetbrains.kotlin.platform.jvm.isJvm
|
|||||||
object JvmIdePlatformKind : IdePlatformKind() {
|
object JvmIdePlatformKind : IdePlatformKind() {
|
||||||
override fun supportsTargetPlatform(platform: TargetPlatform): Boolean = platform.isJvm()
|
override fun supportsTargetPlatform(platform: TargetPlatform): Boolean = platform.isJvm()
|
||||||
|
|
||||||
|
private val jvmTargetDescriptionMap by lazy {
|
||||||
|
JvmTarget.values().associateBy { it.description }
|
||||||
|
}
|
||||||
|
|
||||||
override fun platformByCompilerArguments(arguments: CommonCompilerArguments): TargetPlatform? {
|
override fun platformByCompilerArguments(arguments: CommonCompilerArguments): TargetPlatform? {
|
||||||
if (arguments !is K2JVMCompilerArguments) return null
|
if (arguments !is K2JVMCompilerArguments) return null
|
||||||
|
|
||||||
val jvmTargetDescription = arguments.jvmTarget
|
val jvmTargetDescription = arguments.jvmTarget ?: return JvmPlatforms.defaultJvmPlatform
|
||||||
?: return JvmPlatforms.defaultJvmPlatform
|
val jvmTarget = jvmTargetDescriptionMap[jvmTargetDescription] ?: return JvmPlatforms.defaultJvmPlatform
|
||||||
|
|
||||||
val jvmTarget = JvmTarget.values()
|
|
||||||
.firstOrNull { VersionComparatorUtil.COMPARATOR.compare(it.description, jvmTargetDescription) >= 0 }
|
|
||||||
?: return JvmPlatforms.defaultJvmPlatform
|
|
||||||
|
|
||||||
return JvmPlatforms.jvmPlatformByTargetVersion(jvmTarget)
|
return JvmPlatforms.jvmPlatformByTargetVersion(jvmTarget)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user