FIR2IR: Imitate K1 behavior when SAM type has a bit different shape

See the relevant test at t/
estData/codegen/box/sam/contravariantIntersectionType.kt

After the previous commit, when generating a call for `doOnSuccess {}`,
we have a SAM type with removed projection Consumer<Any?>, while
real function type of the lambda is a bit different
(Function1<ConcreteType & ConcreteType2>).

While for me, that looks questionable, but in K1 it was effectively
resolved via the same implicit cast that on JVM is generated to an
INVOKEDYNAMIC that wraps initial function-typed value.

^KT-53552 Fixed
This commit is contained in:
Denis.Zharkov
2023-02-15 16:07:20 +01:00
committed by Space Team
parent 05ca001310
commit 99448b77f3
4 changed files with 55 additions and 32 deletions
+1 -1
View File
@@ -7,5 +7,5 @@ fun box(): String {
return map.computeIfAbsent(p0 = fn, p1 = local fun <anonymous>(it: @EnhancedNullability Fun): @EnhancedNullability String {
return "OK"
}
/*-> @EnhancedNullability Function<Any?, @EnhancedNullability String> */) /*!! String */
/*as Function1<@EnhancedNullability Any?, @EnhancedNullability String> */ /*-> @EnhancedNullability Function<Any?, @EnhancedNullability String> */) /*!! String */
}