[Stubs] Fix contract deserialization for non-JVM stubs
Types serialized via type table weren't deserialized, which led to missing contract information in stubs. KTIJ-28668
This commit is contained in:
committed by
Space Team
parent
9373437cad
commit
bfb1ef14f5
Vendored
-2
@@ -1,5 +1,3 @@
|
||||
/* KTIJ-28668 */
|
||||
// KNM_K2_IGNORE
|
||||
// JVM_FILE_NAME: ContractsKt
|
||||
|
||||
@file:OptIn(ExperimentalContracts::class)
|
||||
|
||||
+5
-3
@@ -16,6 +16,8 @@ import org.jetbrains.kotlin.psi.stubs.impl.*
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinContractEffectType.Companion.IGNORE_REFERENCE_PARAMETER_NAME
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ProtoBufContractDeserializer
|
||||
import org.jetbrains.kotlin.serialization.deserialization.getClassId
|
||||
import org.jetbrains.kotlin.metadata.deserialization.type
|
||||
import org.jetbrains.kotlin.metadata.deserialization.receiverType
|
||||
|
||||
class ClsContractBuilder(private val c: ClsStubBuilderContext, private val typeStubBuilder: TypeClsStubBuilder) :
|
||||
ProtoBufContractDeserializer<KotlinTypeBean, Nothing?, ProtoBuf.Function>() {
|
||||
@@ -26,9 +28,9 @@ class ClsContractBuilder(private val c: ClsStubBuilderContext, private val typeS
|
||||
|
||||
override fun extractVariable(valueParameterIndex: Int, owner: ProtoBuf.Function): KtValueParameterReference<KotlinTypeBean, Nothing?> {
|
||||
val type = if (valueParameterIndex < 0) {
|
||||
owner.receiverType
|
||||
} else owner.valueParameterList[valueParameterIndex].type
|
||||
return if (type.hasClassName() && c.nameResolver.getClassId(type.className) == StandardClassIds.Boolean) {
|
||||
owner.receiverType(c.typeTable)
|
||||
} else owner.valueParameterList[valueParameterIndex].type(c.typeTable)
|
||||
return if (type?.hasClassName() == true && c.nameResolver.getClassId(type.className) == StandardClassIds.Boolean) {
|
||||
KtBooleanValueParameterReference(valueParameterIndex, name = IGNORE_REFERENCE_PARAMETER_NAME)
|
||||
} else KtValueParameterReference(valueParameterIndex, name = IGNORE_REFERENCE_PARAMETER_NAME)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user