Kotlin Facet: Reset all coroutine support flags before importing them frm Gradle
This commit is contained in:
@@ -231,11 +231,16 @@ fun parseCompilerArgumentsToFacet(arguments: List<String>, defaultArguments: Lis
|
|||||||
commonCompilerArguments.coroutinesWarn = false
|
commonCompilerArguments.coroutinesWarn = false
|
||||||
commonCompilerArguments.coroutinesError = false
|
commonCompilerArguments.coroutinesError = false
|
||||||
|
|
||||||
|
if (compilerArguments != commonCompilerArguments) {
|
||||||
|
compilerArguments.coroutinesEnable = false
|
||||||
|
compilerArguments.coroutinesWarn = false
|
||||||
|
compilerArguments.coroutinesError = false
|
||||||
|
}
|
||||||
|
|
||||||
parseArguments(argumentArray, compilerArguments, true)
|
parseArguments(argumentArray, compilerArguments, true)
|
||||||
|
|
||||||
if (!compilerArguments.coroutinesEnable && !compilerArguments.coroutinesWarn && !compilerArguments.coroutinesError) {
|
val restoreCoroutineSupport =
|
||||||
compilerInfo.coroutineSupport = oldCoroutineSupport
|
!compilerArguments.coroutinesEnable && !compilerArguments.coroutinesWarn && !compilerArguments.coroutinesError
|
||||||
}
|
|
||||||
|
|
||||||
versionInfo.apiLevel = LanguageVersion.fromVersionString(compilerArguments.apiVersion)
|
versionInfo.apiLevel = LanguageVersion.fromVersionString(compilerArguments.apiVersion)
|
||||||
versionInfo.languageLevel = LanguageVersion.fromVersionString(compilerArguments.languageVersion)
|
versionInfo.languageLevel = LanguageVersion.fromVersionString(compilerArguments.languageVersion)
|
||||||
@@ -268,5 +273,9 @@ fun parseCompilerArgumentsToFacet(arguments: List<String>, defaultArguments: Lis
|
|||||||
}
|
}
|
||||||
|
|
||||||
copyInheritedFields(compilerArguments, commonCompilerArguments)
|
copyInheritedFields(compilerArguments, commonCompilerArguments)
|
||||||
|
|
||||||
|
if (restoreCoroutineSupport) {
|
||||||
|
compilerInfo.coroutineSupport = oldCoroutineSupport
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,6 +109,54 @@ class GradleFacetImportTest : GradleImportingTestCase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testFixCorruptedCoroutines() {
|
||||||
|
createProjectSubFile("build.gradle", """
|
||||||
|
group 'Again'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
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-beta-38")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0-beta-38"
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
experimental {
|
||||||
|
coroutines 'enable'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
|
||||||
|
importProject()
|
||||||
|
|
||||||
|
with (facetSettings) {
|
||||||
|
compilerInfo.k2jvmCompilerArguments!!.coroutinesEnable = true
|
||||||
|
compilerInfo.k2jvmCompilerArguments!!.coroutinesWarn = true
|
||||||
|
compilerInfo.k2jvmCompilerArguments!!.coroutinesError = true
|
||||||
|
|
||||||
|
importProject()
|
||||||
|
|
||||||
|
Assert.assertEquals(CoroutineSupport.ENABLED, compilerInfo.coroutineSupport)
|
||||||
|
Assert.assertEquals(true, compilerInfo.k2jvmCompilerArguments!!.coroutinesEnable)
|
||||||
|
Assert.assertEquals(false, compilerInfo.k2jvmCompilerArguments!!.coroutinesWarn)
|
||||||
|
Assert.assertEquals(false, compilerInfo.k2jvmCompilerArguments!!.coroutinesError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testCoroutineImportByProperties() {
|
fun testCoroutineImportByProperties() {
|
||||||
createProjectSubFile("gradle.properties", "kotlin.coroutines=enable")
|
createProjectSubFile("gradle.properties", "kotlin.coroutines=enable")
|
||||||
|
|||||||
Reference in New Issue
Block a user