Remove platform comparisons based on string dictionary order (KT-30356)
Comparison was changed in https://github.com/JetBrains/kotlin/commit/641a9a7153ebb3562c67a86e3ea6edda8360cec9#diff-0895a6eaf69b9fd4d43f83db9889d103R109 #KT-30356 Fixed
This commit is contained in:
@@ -4,8 +4,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@file:JvmName("JvmIdePlatformUtil")
|
@file:JvmName("JvmIdePlatformUtil")
|
||||||
|
|
||||||
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
|
||||||
@@ -18,7 +20,9 @@ object JvmIdePlatformKind : IdePlatformKind<JvmIdePlatformKind>() {
|
|||||||
override fun platformByCompilerArguments(arguments: CommonCompilerArguments): IdePlatform<JvmIdePlatformKind, CommonCompilerArguments>? {
|
override fun platformByCompilerArguments(arguments: CommonCompilerArguments): IdePlatform<JvmIdePlatformKind, CommonCompilerArguments>? {
|
||||||
return if (arguments is K2JVMCompilerArguments) {
|
return if (arguments is K2JVMCompilerArguments) {
|
||||||
val jvmTarget = arguments.jvmTarget ?: JvmTarget.DEFAULT.description
|
val jvmTarget = arguments.jvmTarget ?: JvmTarget.DEFAULT.description
|
||||||
JvmIdePlatformKind.platforms.firstOrNull { it.version.description >= jvmTarget }
|
platforms.firstOrNull { platform ->
|
||||||
|
VersionComparatorUtil.COMPARATOR.compare(platform.version.description, jvmTarget) >= 0
|
||||||
|
}
|
||||||
} else null
|
} else null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="KotlinJavaRuntime (2)" level="project" />
|
||||||
|
</component>
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
|
<configuration version="3" platform="JVM 1.8" useProjectSettings="false">
|
||||||
|
<compilerSettings>
|
||||||
|
<option name="additionalArguments" value="-version -Xallow-kotlin-package -Xskip-metadata-version-check" />
|
||||||
|
</compilerSettings>
|
||||||
|
<compilerArguments>
|
||||||
|
<option name="jvmTarget" value="11" />
|
||||||
|
<option name="languageVersion" value="1.1" />
|
||||||
|
<option name="apiVersion" value="1.0" />
|
||||||
|
<option name="coroutinesState" value="enable" />
|
||||||
|
</compilerArguments>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<resourceExtensions />
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="false">
|
||||||
|
<processorPath useClasspath="true" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/module.iml" filepath="$PROJECT_DIR$/module.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="KotlinJavaRuntime (2)">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/../mockRuntime11/kotlin-runtime.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -271,6 +271,11 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
|
|||||||
assertEquals("-version -Xallow-kotlin-package -Xskip-metadata-version-check", settings.getCompilerSettings().getAdditionalArguments());
|
assertEquals("-version -Xallow-kotlin-package -Xskip-metadata-version-check", settings.getCompilerSettings().getAdditionalArguments());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testJvmProjectWithJvmTarget11() {
|
||||||
|
KotlinFacetSettings settings = KotlinFacetSettingsProvider.Companion.getInstance(myProject).getInitializedSettings(getModule());
|
||||||
|
assertEquals(new JvmIdePlatformKind.Platform(JvmTarget.JVM_11), settings.getPlatform());
|
||||||
|
}
|
||||||
|
|
||||||
public void testImplementsDependency() {
|
public void testImplementsDependency() {
|
||||||
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
|
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
|
||||||
|
|
||||||
|
|||||||
@@ -271,6 +271,11 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
|
|||||||
assertEquals("-version -Xallow-kotlin-package -Xskip-metadata-version-check", settings.getCompilerSettings().getAdditionalArguments());
|
assertEquals("-version -Xallow-kotlin-package -Xskip-metadata-version-check", settings.getCompilerSettings().getAdditionalArguments());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testJvmProjectWithJvmTarget11() {
|
||||||
|
KotlinFacetSettings settings = KotlinFacetSettingsProvider.Companion.getInstance(myProject).getInitializedSettings(getModule());
|
||||||
|
assertEquals(new JvmIdePlatformKind.Platform(JvmTarget.JVM_11), settings.getPlatform());
|
||||||
|
}
|
||||||
|
|
||||||
public void testImplementsDependency() {
|
public void testImplementsDependency() {
|
||||||
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
|
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user