K2: add explicit cast to Any for Any function calls on stub types

This commit solves a stub type inconsistency problem.
As a part of KT-59369 fix we decided (see commit 299d2799),
that ConeStubTypeForChainInference has a scope of Any,
so we can safely resolve only to equals/hashCode/toString.
However, later we can replace a stub type with some inferred type,
which can have its own equals/hashCode/toString implementation,
while the call still refers Any member.
In this situation FIR2IR decides that we are calling a fake override,
which is not true, in fact we are calling an overriding method.
This leads to a crash in Native backend.

To solve this situation, we provide an explicit cast of a dispatch
receiver with a stub type (ConeStubTypeForChainInference) to Any,
thus confirming directly we are calling Any method and nothing else.

#KT-63932 Fixed
This commit is contained in:
Mikhail Glukhikh
2023-12-11 18:13:06 +01:00
committed by Space Team
parent a0deaea8fe
commit dbca7358af
13 changed files with 196 additions and 2 deletions
@@ -1,5 +1,4 @@
// WITH_STDLIB
// IGNORE_BACKEND_K2: NATIVE
import kotlin.experimental.ExperimentalTypeInference