Kotlin Facet: Ensure that API version <= language version after import
#KT-20603 Fixed
This commit is contained in:
+37
@@ -1581,6 +1581,43 @@ compileTestKotlin {
|
|||||||
Assert.assertEquals("MultiTest_myTest", facetSettings("MultiTest-js_myTest").implementedModuleName)
|
Assert.assertEquals("MultiTest_myTest", facetSettings("MultiTest-js_myTest").implementedModuleName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testAPIVersionExceedingLanguageVersion() {
|
||||||
|
createProjectSubFile("build.gradle", """
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url 'http://dl.bintray.com/kotlin/kotlin-eap-1.1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlin {
|
||||||
|
kotlinOptions.languageVersion = "1.1"
|
||||||
|
kotlinOptions.apiVersion = "1.2"
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
importProject()
|
||||||
|
|
||||||
|
with (facetSettings) {
|
||||||
|
Assert.assertEquals("1.1", languageLevel!!.versionString)
|
||||||
|
Assert.assertEquals("1.1", apiLevel!!.versionString)
|
||||||
|
}
|
||||||
|
|
||||||
|
assertAllModulesConfigured()
|
||||||
|
}
|
||||||
|
|
||||||
private fun assertAllModulesConfigured() {
|
private fun assertAllModulesConfigured() {
|
||||||
runReadAction {
|
runReadAction {
|
||||||
for (moduleGroup in ModuleSourceRootMap(myProject).groupByBaseModules(myProject.allModules())) {
|
for (moduleGroup in ModuleSourceRootMap(myProject).groupByBaseModules(myProject.allModules())) {
|
||||||
|
|||||||
@@ -310,6 +310,12 @@ fun parseCompilerArgumentsToFacet(
|
|||||||
copyFieldsSatisfying(this, compilerArguments) { exposeAsAdditionalArgument(it) || it.name in ignoredFields }
|
copyFieldsSatisfying(this, compilerArguments) { exposeAsAdditionalArgument(it) || it.name in ignoredFields }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val languageLevel = languageLevel
|
||||||
|
val apiLevel = apiLevel
|
||||||
|
if (languageLevel != null && apiLevel != null && apiLevel > languageLevel) {
|
||||||
|
this.apiLevel = languageLevel
|
||||||
|
}
|
||||||
|
|
||||||
updateMergedArguments()
|
updateMergedArguments()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user