From ac0f5548aa0d616bbaf87397921b278c09580b2f Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 19 Jul 2018 16:12:55 +0200 Subject: [PATCH] Only check language version in MemberDeserializer.loadAsSuspend This is still not 100% foolproof because one may place such a requirement manually on a suspend function (with `@RequireKotlin`, for example), which will trick the compiler into thinking that this is a new suspend function, even if it was compiled with old coroutines. But it's still better than only checking the version number --- .../serialization/deserialization/MemberDeserializer.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt index 73d1d6222fa..bacb40bac3c 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt @@ -137,7 +137,9 @@ class MemberDeserializer(private val c: DeserializationContext) { } private fun DeserializedMemberDescriptor.versionAndReleaseCoroutinesMismatch(): Boolean = - c.components.configuration.releaseCoroutines && versionRequirements.none { it.version == VersionRequirement.Version(1, 3) } + c.components.configuration.releaseCoroutines && versionRequirements.none { + it.version == VersionRequirement.Version(1, 3) && it.kind == ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION + } private fun loadOldFlags(oldFlags: Int): Int { val lowSixBits = oldFlags and 0x3f @@ -229,8 +231,7 @@ class MemberDeserializer(private val c: DeserializationContext) { descriptor.typeParameters.forEach { it.upperBounds } descriptor.isExperimentalCoroutineInReleaseEnvironment = local.typeDeserializer.experimentalSuspendFunctionTypeEncountered || ((c.containingDeclaration as? DeserializedClassDescriptor)?.c?.typeDeserializer?.experimentalSuspendFunctionTypeEncountered == true && - c.components.configuration.releaseCoroutines && - descriptor.versionRequirements.none { it.version == VersionRequirement.Version(1, 3) }) + descriptor.versionAndReleaseCoroutinesMismatch()) return descriptor }