[FIR2IR] Consolidate type approximation

This commit gets rid of the redundant typeApproximatorConfiguration
in Fir2IrTypeConverter and uses the type approximator for captured
types instead of the manual approximation used before.

This fixes the nullability of approximated captured types, which fixes
a runtime error in WASM.

This also brings K2 IR closer to K1 IR in one test.

#KT-64261 Fixed
This commit is contained in:
Kirill Rakhman
2023-12-21 13:16:33 +01:00
committed by Space Team
parent 52a1ffb312
commit 49ae1b8d01
26 changed files with 281 additions and 22 deletions
@@ -77,7 +77,7 @@ FILE fqName:<root> fileName:/genericFunWithStar.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun bar (vararg serializers: <root>.I<*>): <root>.I<*> declared in <root>.Box'
CALL 'public abstract fun foo <F> (tSerializer: <root>.I<F of <root>.Box.foo>): <root>.I<<root>.Box<F of <root>.Box.foo>> declared in <root>.Box' type=<root>.I<out <root>.Box<*>> origin=null
<F>: <root>.IFoo
<F>: <root>.IBase
$this: GET_VAR '<this>: <root>.Box<T of <root>.Box> declared in <root>.Box.bar' type=<root>.Box<T of <root>.Box> origin=null
tSerializer: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array declared in kotlin.Array' type=<root>.I<*> origin=null
$this: GET_VAR 'serializers: kotlin.Array<out <root>.I<*>> declared in <root>.Box.bar' type=kotlin.Array<out <root>.I<*>> origin=null
@@ -20,7 +20,7 @@ abstract class Box<T> : IFoo, IBar where T : IFoo, T : IBar {
abstract fun <F> foo(tSerializer: I<F>): I<Box<F>> where F : IFoo, F : IBar
fun bar(vararg serializers: I<*>): I<*> {
return <this>.foo<IFoo>(tSerializer = serializers.get(index = 0))
return <this>.foo<IBase>(tSerializer = serializers.get(index = 0))
}
}