Generate version requirement on inline functions since API version 1.4

The old compiler will crash if it tries to inline a function that's
passing a lambda parameter into the new parameter null check method
`Intrinsics.checkNotNullParameter` because that usage is not considered as
inlinable by the old compiler (it only knows about
`Intrinsics.checkParameterIsNotNull`). Therefore we require that these
functions can only be read by compilers of version 1.3.50 or greater.

 #KT-22275 Fixed
This commit is contained in:
Alexander Udalov
2019-08-07 15:44:30 +02:00
parent e207c96336
commit b970a57adb
9 changed files with 82 additions and 17 deletions
@@ -67,14 +67,17 @@ class KotlinJavascriptSerializerExtension(
super.serializeProperty(descriptor, proto, versionRequirementTable, childSerializer)
}
override fun serializeFunction(descriptor: FunctionDescriptor,
proto: ProtoBuf.Function.Builder,
childSerializer: DescriptorSerializer) {
override fun serializeFunction(
descriptor: FunctionDescriptor,
proto: ProtoBuf.Function.Builder,
versionRequirementTable: MutableVersionRequirementTable?,
childSerializer: DescriptorSerializer
) {
val id = getFileId(descriptor)
if (id != null) {
proto.setExtension(JsProtoBuf.functionContainingFileId, id)
}
super.serializeFunction(descriptor, proto, childSerializer)
super.serializeFunction(descriptor, proto, versionRequirementTable, childSerializer)
}
private fun getFileId(descriptor: DeclarationDescriptor): Int? {