[FIR2IR] Fix cast insertion for SAM conversion
The rule is: no cast is required iff the argument type is a non-reflection function type and a subtype of the expected function type. We approximate the cone types using the FIR2IR specific config to account for intersection types, captured types, etc. #KT-63345 Fixed #KT-63510 #KT-62865
This commit is contained in:
committed by
Space Team
parent
dd1d36816b
commit
b857c28ab3
+2
-1
@@ -99,7 +99,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.J' type=<root>.J origin=null
|
||||
r: TYPE_OP type=java.lang.Runnable origin=SAM_CONVERSION typeOperand=java.lang.Runnable
|
||||
GET_VAR 'a: kotlin.Function1<kotlin.Int, kotlin.Int> declared in <root>.test7' type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=null
|
||||
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function0<kotlin.Unit>
|
||||
GET_VAR 'a: kotlin.Function1<kotlin.Int, kotlin.Int> declared in <root>.test7' type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=null
|
||||
FUN name:test8 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ fun test6(a: Any) {
|
||||
|
||||
fun test7(a: Function1<Int, Int>) {
|
||||
a as Function0<Unit> /*~> Unit */
|
||||
J().run1(r = a /*-> Runnable */)
|
||||
J().run1(r = a /*as Function0<Unit> */ /*-> Runnable */)
|
||||
}
|
||||
|
||||
fun test8(a: Function0<Unit>) {
|
||||
|
||||
Reference in New Issue
Block a user