JS: prohibit using experimental coroutines from 1.3
This commit is contained in:
+1
-1
@@ -208,7 +208,7 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
// Ideally, we should run full resolution (with all classifier usage checkers) on classifiers used in "-Xexperimental" and
|
||||
// "-Xuse-experimental" arguments. However, it's not easy to do this. This should be solved in the future with the support of
|
||||
// module annotations. For now, we only check deprecations because this is needed to correctly retire unneeded compiler arguments.
|
||||
val deprecationResolver = DeprecationResolver(LockBasedStorageManager(), languageVersionSettings)
|
||||
val deprecationResolver = DeprecationResolver(LockBasedStorageManager(), languageVersionSettings, CoroutineCompatibilitySupport.ENABLED)
|
||||
|
||||
fun checkAnnotation(fqName: String): Boolean {
|
||||
val descriptor = module.resolveClassByFqName(FqName(fqName), NoLookupLocation.FOR_NON_TRACKED_SCOPE)
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.container.DefaultImplementation
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.DescriptorDerivedFromTypeAlias
|
||||
@@ -218,9 +219,21 @@ enum class DeprecationLevelValue {
|
||||
WARNING, ERROR, HIDDEN
|
||||
}
|
||||
|
||||
@DefaultImplementation(CoroutineCompatibilitySupport::class)
|
||||
class CoroutineCompatibilitySupport private constructor(val enabled: Boolean) {
|
||||
constructor() : this(true)
|
||||
|
||||
companion object {
|
||||
val ENABLED = CoroutineCompatibilitySupport(true)
|
||||
|
||||
val DISABLED = CoroutineCompatibilitySupport(false)
|
||||
}
|
||||
}
|
||||
|
||||
class DeprecationResolver(
|
||||
storageManager: StorageManager,
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
private val languageVersionSettings: LanguageVersionSettings,
|
||||
private val coroutineCompatibilitySupport: CoroutineCompatibilitySupport
|
||||
) {
|
||||
private val deprecations = storageManager.createMemoizedFunction { descriptor: DeclarationDescriptor ->
|
||||
val deprecations = descriptor.getOwnDeprecations()
|
||||
@@ -364,10 +377,13 @@ class DeprecationResolver(
|
||||
|
||||
private fun getDeprecationByCoroutinesVersion(target: DeclarationDescriptor): DeprecatedExperimentalCoroutine? {
|
||||
if (target !is DeserializedMemberDescriptor) return null
|
||||
return when (target.coroutinesExperimentalCompatibilityMode) {
|
||||
COMPATIBLE -> null
|
||||
NEEDS_WRAPPER -> DeprecatedExperimentalCoroutine(target, WARNING)
|
||||
INCOMPATIBLE -> DeprecatedExperimentalCoroutine(target, ERROR)
|
||||
|
||||
target.coroutinesExperimentalCompatibilityMode.let { mode ->
|
||||
return when {
|
||||
mode == COMPATIBLE -> null
|
||||
mode == NEEDS_WRAPPER && coroutineCompatibilitySupport.enabled -> DeprecatedExperimentalCoroutine(target, WARNING)
|
||||
else -> DeprecatedExperimentalCoroutine(target, ERROR)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user