Files
kotlin-fork/compiler/testData/ir/irText/firProblems/kt19251.fir.kt.txt
T
Denis.Zharkov 99448b77f3 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
2023-02-20 14:54:09 +00:00

12 lines
529 B
Kotlin
Vendored

fun box(): String {
val map: MutableMap<Fun, String> = mutableMapOf<Fun, String>()
val fn: Fun = local fun <anonymous>(it: @FlexibleNullability String?): @FlexibleNullability String? {
TODO()
}
/*-> Fun */
return map.computeIfAbsent(p0 = fn, p1 = local fun <anonymous>(it: @EnhancedNullability Fun): @EnhancedNullability String {
return "OK"
}
/*as Function1<@EnhancedNullability Any?, @EnhancedNullability String> */ /*-> @EnhancedNullability Function<Any?, @EnhancedNullability String> */) /*!! String */
}