JS: prohibit using experimental coroutines from 1.3
This commit is contained in:
@@ -138,7 +138,7 @@ class GenerationState private constructor(
|
|||||||
val deserializationConfiguration: DeserializationConfiguration =
|
val deserializationConfiguration: DeserializationConfiguration =
|
||||||
CompilerDeserializationConfiguration(configuration.languageVersionSettings)
|
CompilerDeserializationConfiguration(configuration.languageVersionSettings)
|
||||||
|
|
||||||
val deprecationProvider = DeprecationResolver(LockBasedStorageManager.NO_LOCKS, configuration.languageVersionSettings)
|
val deprecationProvider = DeprecationResolver(LockBasedStorageManager.NO_LOCKS, configuration.languageVersionSettings, CoroutineCompatibilitySupport.ENABLED)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val icComponents = configuration.get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS)
|
val icComponents = configuration.get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS)
|
||||||
|
|||||||
+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
|
// 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
|
// "-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.
|
// 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 {
|
fun checkAnnotation(fqName: String): Boolean {
|
||||||
val descriptor = module.resolveClassByFqName(FqName(fqName), NoLookupLocation.FOR_NON_TRACKED_SCOPE)
|
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 com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.config.*
|
import org.jetbrains.kotlin.config.*
|
||||||
|
import org.jetbrains.kotlin.container.DefaultImplementation
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.impl.DescriptorDerivedFromTypeAlias
|
import org.jetbrains.kotlin.descriptors.impl.DescriptorDerivedFromTypeAlias
|
||||||
@@ -218,9 +219,21 @@ enum class DeprecationLevelValue {
|
|||||||
WARNING, ERROR, HIDDEN
|
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(
|
class DeprecationResolver(
|
||||||
storageManager: StorageManager,
|
storageManager: StorageManager,
|
||||||
private val languageVersionSettings: LanguageVersionSettings
|
private val languageVersionSettings: LanguageVersionSettings,
|
||||||
|
private val coroutineCompatibilitySupport: CoroutineCompatibilitySupport
|
||||||
) {
|
) {
|
||||||
private val deprecations = storageManager.createMemoizedFunction { descriptor: DeclarationDescriptor ->
|
private val deprecations = storageManager.createMemoizedFunction { descriptor: DeclarationDescriptor ->
|
||||||
val deprecations = descriptor.getOwnDeprecations()
|
val deprecations = descriptor.getOwnDeprecations()
|
||||||
@@ -364,10 +377,13 @@ class DeprecationResolver(
|
|||||||
|
|
||||||
private fun getDeprecationByCoroutinesVersion(target: DeclarationDescriptor): DeprecatedExperimentalCoroutine? {
|
private fun getDeprecationByCoroutinesVersion(target: DeclarationDescriptor): DeprecatedExperimentalCoroutine? {
|
||||||
if (target !is DeserializedMemberDescriptor) return null
|
if (target !is DeserializedMemberDescriptor) return null
|
||||||
return when (target.coroutinesExperimentalCompatibilityMode) {
|
|
||||||
COMPATIBLE -> null
|
target.coroutinesExperimentalCompatibilityMode.let { mode ->
|
||||||
NEEDS_WRAPPER -> DeprecatedExperimentalCoroutine(target, WARNING)
|
return when {
|
||||||
INCOMPATIBLE -> DeprecatedExperimentalCoroutine(target, ERROR)
|
mode == COMPATIBLE -> null
|
||||||
|
mode == NEEDS_WRAPPER && coroutineCompatibilitySupport.enabled -> DeprecatedExperimentalCoroutine(target, WARNING)
|
||||||
|
else -> DeprecatedExperimentalCoroutine(target, ERROR)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
import kotlin.coroutines.experimental.*
|
||||||
|
import kotlin.coroutines.experimental.intrinsics.*
|
||||||
|
|
||||||
|
suspend fun dummy(): String = <!DEPRECATION_ERROR!>suspendCoroutine<!> {
|
||||||
|
it.resume("OK")
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public suspend fun dummy(): kotlin.String
|
||||||
+5
@@ -383,6 +383,11 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLib/module"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLib/module"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("coroutineProhibitedMigration.kt")
|
||||||
|
public void testCoroutineProhibitedMigration() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithJsStdLib/module/coroutineProhibitedMigration.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("dualModuleFromUmd.kt")
|
@TestMetadata("dualModuleFromUmd.kt")
|
||||||
public void testDualModuleFromUmd() throws Exception {
|
public void testDualModuleFromUmd() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/testsWithJsStdLib/module/dualModuleFromUmd.kt");
|
runTest("compiler/testData/diagnostics/testsWithJsStdLib/module/dualModuleFromUmd.kt");
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ import org.jetbrains.kotlin.container.useInstance
|
|||||||
import org.jetbrains.kotlin.js.analyze.JsNativeDiagnosticSuppressor
|
import org.jetbrains.kotlin.js.analyze.JsNativeDiagnosticSuppressor
|
||||||
import org.jetbrains.kotlin.js.naming.NameSuggestion
|
import org.jetbrains.kotlin.js.naming.NameSuggestion
|
||||||
import org.jetbrains.kotlin.js.resolve.diagnostics.*
|
import org.jetbrains.kotlin.js.resolve.diagnostics.*
|
||||||
import org.jetbrains.kotlin.resolve.DeclarationReturnTypeSanitizer
|
import org.jetbrains.kotlin.resolve.*
|
||||||
import org.jetbrains.kotlin.resolve.OverloadFilter
|
|
||||||
import org.jetbrains.kotlin.resolve.OverridesBackwardCompatibilityHelper
|
|
||||||
import org.jetbrains.kotlin.resolve.PlatformConfigurator
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.checkers.ReifiedTypeParameterSubstitutionChecker
|
import org.jetbrains.kotlin.resolve.calls.checkers.ReifiedTypeParameterSubstitutionChecker
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.SamConversionTransformer
|
import org.jetbrains.kotlin.resolve.calls.components.SamConversionTransformer
|
||||||
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker
|
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker
|
||||||
@@ -76,5 +73,6 @@ object JsPlatformConfigurator : PlatformConfigurator(
|
|||||||
container.useInstance(ExtensionFunctionToExternalIsInlinable)
|
container.useInstance(ExtensionFunctionToExternalIsInlinable)
|
||||||
container.useInstance(JsQualifierChecker)
|
container.useInstance(JsQualifierChecker)
|
||||||
container.useInstance(JsNativeDiagnosticSuppressor)
|
container.useInstance(JsNativeDiagnosticSuppressor)
|
||||||
|
container.useInstance(CoroutineCompatibilitySupport.DISABLED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user