[FIR2IR] Fix SAM conversion of adapted callable reference

#KT-63329 Fixed
This commit is contained in:
Kirill Rakhman
2023-11-30 13:19:34 +01:00
committed by Space Team
parent c8b77fe18c
commit 2391f00b75
11 changed files with 71 additions and 53 deletions
@@ -28,12 +28,12 @@ FILE fqName:<root> fileName:/withAdaptationForSam.kt
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun useFoo (foo: <root>.IFoo): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
foo: TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo
BLOCK type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int
BLOCK_BODY
CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.Int declared in <root>' type=kotlin.Int origin=null
xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int
GET_VAR 'p0: kotlin.Int declared in <root>.test.withVararg' type=kotlin.Int origin=null
foo: BLOCK type=<root>.IFoo origin=ADAPTED_FUNCTION_REFERENCE
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int
BLOCK_BODY
CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.Int declared in <root>' type=kotlin.Int origin=null
xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int
GET_VAR 'p0: kotlin.Int declared in <root>.test.withVararg' type=kotlin.Int origin=null
TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo
FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in <root>.test' type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun withVararg (vararg xs: kotlin.Int): kotlin.Int declared in <root>
@@ -16,7 +16,7 @@ fun test() {
withVararg(xs = [p0])
}
::withVararg
} /*-> IFoo */)
::withVararg /*-> IFoo */
})
}
@@ -65,12 +65,12 @@ FILE fqName:<root> fileName:/samConversionInVarargs.kt
BLOCK_BODY
CALL 'public final fun useVararg (vararg foos: <root>.IFoo): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
foos: VARARG type=kotlin.Array<out <root>.IFoo> varargElementType=<root>.IFoo
TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo
BLOCK type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVarargOfInt visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int
BLOCK_BODY
CALL 'public final fun withVarargOfInt (vararg xs: kotlin.Int): kotlin.String declared in <root>' type=kotlin.String origin=null
xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int
GET_VAR 'p0: kotlin.Int declared in <root>.testAdaptedCR.withVarargOfInt' type=kotlin.Int origin=null
BLOCK type=<root>.IFoo origin=ADAPTED_FUNCTION_REFERENCE
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVarargOfInt visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int
BLOCK_BODY
CALL 'public final fun withVarargOfInt (vararg xs: kotlin.Int): kotlin.String declared in <root>' type=kotlin.String origin=null
xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int
GET_VAR 'p0: kotlin.Int declared in <root>.testAdaptedCR.withVarargOfInt' type=kotlin.Int origin=null
TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo
FUNCTION_REFERENCE 'local final fun withVarargOfInt (p0: kotlin.Int): kotlin.Unit declared in <root>.testAdaptedCR' type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun withVarargOfInt (vararg xs: kotlin.Int): kotlin.String declared in <root>
@@ -36,7 +36,7 @@ fun testAdaptedCR() {
withVarargOfInt(xs = [p0])
}
::withVarargOfInt
} /*-> IFoo */])
::withVarargOfInt /*-> IFoo */
}])
}
@@ -48,9 +48,9 @@ FILE fqName:<root> fileName:/samConversionOnCallableReference.kt
FUN name:testSamConversionOnAdapted visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun use (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
BLOCK type=kotlin.Function0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo1 visibility:local modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in <root>' type=kotlin.Int origin=null
r: BLOCK type=<root>.KRunnable origin=ADAPTED_FUNCTION_REFERENCE
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo1 visibility:local modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in <root>' type=kotlin.Int origin=null
TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
FUNCTION_REFERENCE 'local final fun foo1 (): kotlin.Unit declared in <root>.testSamConversionOnAdapted' type=kotlin.Function0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in <root>
@@ -37,7 +37,7 @@ fun testSamConversionOnAdapted() {
foo1()
}
::foo1
} /*-> KRunnable */)
::foo1 /*-> KRunnable */
})
}
@@ -40,23 +40,23 @@ FILE fqName:<root> fileName:/suspendConversionWithFunInterfaces.kt
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun foo1 (s: <root>.SuspendRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
s: TYPE_OP type=<root>.SuspendRunnable origin=SAM_CONVERSION typeOperand=<root>.SuspendRunnable
BLOCK type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:bar1 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend]
BLOCK_BODY
CALL 'public final fun bar1 (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
s: BLOCK type=<root>.SuspendRunnable origin=ADAPTED_FUNCTION_REFERENCE
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:bar1 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend]
BLOCK_BODY
CALL 'public final fun bar1 (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
TYPE_OP type=<root>.SuspendRunnable origin=SAM_CONVERSION typeOperand=<root>.SuspendRunnable
FUNCTION_REFERENCE 'local final fun bar1 (): kotlin.Unit declared in <root>.box' type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun bar1 (): kotlin.Unit declared in <root>
CALL 'public final fun foo1 (s: <root>.SuspendRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
s: TYPE_OP type=<root>.SuspendRunnable origin=SAM_CONVERSION typeOperand=<root>.SuspendRunnable
BLOCK type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:bar2 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend]
BLOCK_BODY
CALL 'public final fun bar2 (s: kotlin.String): kotlin.Int declared in <root>' type=kotlin.Int origin=null
s: BLOCK type=<root>.SuspendRunnable origin=ADAPTED_FUNCTION_REFERENCE
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:bar2 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend]
BLOCK_BODY
CALL 'public final fun bar2 (s: kotlin.String): kotlin.Int declared in <root>' type=kotlin.Int origin=null
TYPE_OP type=<root>.SuspendRunnable origin=SAM_CONVERSION typeOperand=<root>.SuspendRunnable
FUNCTION_REFERENCE 'local final fun bar2 (): kotlin.Unit declared in <root>.box' type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun bar2 (s: kotlin.String): kotlin.Int declared in <root>
CALL 'public final fun foo1 (s: <root>.SuspendRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
s: TYPE_OP type=<root>.SuspendRunnable origin=SAM_CONVERSION typeOperand=<root>.SuspendRunnable
BLOCK type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:bar3 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend]
BLOCK_BODY
CALL 'public final fun bar3 (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
s: BLOCK type=<root>.SuspendRunnable origin=ADAPTED_FUNCTION_REFERENCE
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:bar3 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend]
BLOCK_BODY
CALL 'public final fun bar3 (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
TYPE_OP type=<root>.SuspendRunnable origin=SAM_CONVERSION typeOperand=<root>.SuspendRunnable
FUNCTION_REFERENCE 'local final fun bar3 (): kotlin.Unit declared in <root>.box' type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun bar3 (): kotlin.Unit declared in <root>