[JS] Manually change receiver's type of Char's equals method

Char's equals method in js doesn't work properly because now equals
method is not fake override in Char, but it is actual override and so
when we call equals for some char in js, it will not be boxed. To fix
it we need to get correct receiver's type.
This commit is contained in:
Ivan Kylchik
2022-04-13 22:31:23 +03:00
parent 1564f2c549
commit 4ddbb89103
@@ -16,6 +16,8 @@
package org.jetbrains.kotlin.js.translate.callTranslator
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.contracts.parsing.isEqualsDescriptor
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
@@ -137,8 +139,12 @@ private fun TranslationContext.createCallInfo(
var dispatchReceiver = getDispatchReceiver()
var dispatchReceiverType = resolvedCall.smartCastDispatchReceiverType ?: resolvedCall.dispatchReceiver?.type
if (dispatchReceiverType != null && (resolvedCall.resultingDescriptor as? FunctionDescriptor)?.kind?.isReal == false) {
dispatchReceiverType = TranslationUtils.getDispatchReceiverTypeForCoercion(resolvedCall.resultingDescriptor)
if (dispatchReceiverType != null) {
if ((resolvedCall.resultingDescriptor as? FunctionDescriptor)?.kind?.isReal == false) {
dispatchReceiverType = TranslationUtils.getDispatchReceiverTypeForCoercion(resolvedCall.resultingDescriptor)
} else if (KotlinBuiltIns.isChar(dispatchReceiverType) && resolvedCall.resultingDescriptor.isEqualsDescriptor()) {
dispatchReceiverType = resolvedCall.resultingDescriptor.overriddenDescriptors.single().dispatchReceiverParameter!!.type
}
}
var extensionReceiver = getExtensionReceiver()
var notNullConditional: JsConditional? = null