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
This commit is contained in:
Alexander Udalov
2018-07-19 16:12:55 +02:00
parent c011bf61fe
commit ac0f5548aa
@@ -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
}