FIR. BI: Fix stub type leakage in builder inference

Previously, updateTypeInBuilderInference was calling
updateTypeFromSmartcast to actually perform type update in
implicit receiver after stub types was inferred
Such action results in creation of following FIR:

FirSmartCastExpression(
    original=FQAE(FirImplicitThisReference, typeRef=R|Inv<Stub>|)
    typeRef=R|Inv<String>|
)

in receiver position during completion of calls

However, it wasn't the case in general situation due to
action of FirStubTypeTransformer, which, in turn visits and updates
type ref inside original expression, but only if there was at
least one call (that was completed) using that implicit receiver
As after such type update updateTypeFromSmartcast function does
nothing

Yet in situation, when there was only partially resolved calls
referencing that implicit receiver we actually create smart-cast
expression and don't update type

The change just removes usage of updateTypeFromSmartcast and
replaces is with direct type update
We still mutate state of implicit receiver, potentially
improperly, it should be addressed in future

^KT-54708
^KT-58365 Fixed
This commit is contained in:
Simon Ogorodnik
2023-05-02 15:07:57 +02:00
committed by Space Team
parent af7d6b1bb3
commit 82611ad124
11 changed files with 55 additions and 5 deletions
@@ -1,4 +1,3 @@
// IGNORE_LEAKED_INTERNAL_TYPES: KT-54708
// WITH_STDLIB
import kotlin.experimental.ExperimentalTypeInference