diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt index 84ca52203af..68e4ea3c098 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt @@ -135,7 +135,7 @@ internal class AdapterGenerator( ) irAdapterFunction.body = irFactory.createBlockBody(startOffset, endOffset) { if (expectedReturnType?.isUnit() == true) { - statements.add(irCall) + statements.add(Fir2IrImplicitCastInserter.coerceToUnitIfNeeded(irCall, irBuiltIns)) } else { statements.add(IrReturnImpl(startOffset, endOffset, irBuiltIns.nothingType, irAdapterFunction.symbol, irCall)) } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.fir.ir.txt deleted file mode 100644 index 8f1ea9bbc99..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.fir.ir.txt +++ /dev/null @@ -1,62 +0,0 @@ -FILE fqName: fileName:/adaptedWithCoercionToUnit.kt - FUN name:useUnit0 visibility:public modality:FINAL <> (fn:kotlin.Function0) returnType:kotlin.Unit - VALUE_PARAMETER name:fn index:0 type:kotlin.Function0 - BLOCK_BODY - FUN name:useUnit1 visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Unit - VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 - BLOCK_BODY - FUN name:fn0 visibility:public modality:FINAL <> () returnType:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun fn0 (): kotlin.Int declared in ' - CONST Int type=kotlin.Int value=1 - FUN name:fn1 visibility:public modality:FINAL <> (x:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:x index:0 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun fn1 (x: kotlin.Int): kotlin.Int declared in ' - CONST Int type=kotlin.Int value=1 - FUN name:fnv visibility:public modality:FINAL <> (xs:kotlin.IntArray) returnType:kotlin.Int - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun fnv (vararg xs: kotlin.Int): kotlin.Int declared in ' - CONST Int type=kotlin.Int value=1 - FUN name:test0 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test0 (): kotlin.Unit declared in ' - CALL 'public final fun useUnit0 (fn: kotlin.Function0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fn0 visibility:local modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun fn0 (): kotlin.Int declared in ' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun fn0 (): kotlin.Unit declared in .test0' type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun fn0 (): kotlin.Int declared in - FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.Unit declared in ' - CALL 'public final fun useUnit1 (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fn1 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 fn1 (x: kotlin.Int): kotlin.Int declared in ' type=kotlin.Int origin=null - x: GET_VAR 'p0: kotlin.Int declared in .test1.fn1' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun fn1 (p0: kotlin.Int): kotlin.Unit declared in .test1' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun fn1 (x: kotlin.Int): kotlin.Int declared in - FUN name:testV0 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testV0 (): kotlin.Unit declared in ' - CALL 'public final fun useUnit0 (fn: kotlin.Function0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnv visibility:local modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun fnv (vararg xs: kotlin.Int): kotlin.Int declared in ' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun fnv (): kotlin.Unit declared in .testV0' type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun fnv (vararg xs: kotlin.Int): kotlin.Int declared in - FUN name:testV1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testV1 (): kotlin.Unit declared in ' - CALL 'public final fun useUnit1 (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnv 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 fnv (vararg xs: kotlin.Int): kotlin.Int declared in ' type=kotlin.Int origin=null - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .testV1.fnv' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun fnv (p0: kotlin.Int): kotlin.Unit declared in .testV1' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun fnv (vararg xs: kotlin.Int): kotlin.Int declared in diff --git a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.fir.kt.txt deleted file mode 100644 index 16cbf9acca6..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.fir.kt.txt +++ /dev/null @@ -1,58 +0,0 @@ -fun useUnit0(fn: Function0) { -} - -fun useUnit1(fn: Function1) { -} - -fun fn0(): Int { - return 1 -} - -fun fn1(x: Int): Int { - return 1 -} - -fun fnv(vararg xs: Int): Int { - return 1 -} - -fun test0() { - return useUnit0(fn = { // BLOCK - local fun fn0() { - fn0() - } - - ::fn0 - }) -} - -fun test1() { - return useUnit1(fn = { // BLOCK - local fun fn1(p0: Int) { - fn1(x = p0) - } - - ::fn1 - }) -} - -fun testV0() { - return useUnit0(fn = { // BLOCK - local fun fnv() { - fnv() - } - - ::fnv - }) -} - -fun testV1() { - return useUnit1(fn = { // BLOCK - local fun fnv(p0: Int) { - fnv(xs = [p0]) - } - - ::fnv - }) -} - diff --git a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.kt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.kt index cadfbe356dc..08ebe4bfba4 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.kt +++ b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun useUnit0(fn: () -> Unit) {} fun useUnit1(fn: (Int) -> Unit) {} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.ir.txt deleted file mode 100644 index cf757bec163..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.ir.txt +++ /dev/null @@ -1,24 +0,0 @@ -FILE fqName:test fileName:/boundInlineAdaptedReference.kt - FUN name:foo visibility:public modality:FINAL <> (x:kotlin.Function0) returnType:kotlin.Unit [inline] - VALUE_PARAMETER name:x index:0 type:kotlin.Function0 - BLOCK_BODY - FUN name:id visibility:public modality:FINAL <> ($receiver:kotlin.String, s:kotlin.String, xs:kotlin.IntArray) returnType:kotlin.String - $receiver: VALUE_PARAMETER name: type:kotlin.String - VALUE_PARAMETER name:s index:0 type:kotlin.String - EXPRESSION_BODY - GET_VAR ': kotlin.String declared in test.id' type=kotlin.String origin=null - VALUE_PARAMETER name:xs index:1 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun id (s: kotlin.String, vararg xs: kotlin.Int): kotlin.String declared in test' - GET_VAR 's: kotlin.String declared in test.id' type=kotlin.String origin=null - FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun foo (x: kotlin.Function0): kotlin.Unit declared in test' type=kotlin.Unit origin=null - x: BLOCK type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:id visibility:local modality:FINAL <> ($receiver:kotlin.String) returnType:kotlin.Unit - $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:kotlin.String - BLOCK_BODY - CALL 'public final fun id (s: kotlin.String, vararg xs: kotlin.Int): kotlin.String declared in test' type=kotlin.String origin=null - $receiver: GET_VAR 'receiver: kotlin.String declared in test.test.id' type=kotlin.String origin=ADAPTED_FUNCTION_REFERENCE - FUNCTION_REFERENCE 'local final fun id (): kotlin.Unit declared in test.test' type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun id (s: kotlin.String, vararg xs: kotlin.Int): kotlin.String declared in test - $receiver: CONST String type=kotlin.String value="Fail" diff --git a/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.kt.txt deleted file mode 100644 index 78394c432fc..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.kt.txt +++ /dev/null @@ -1,18 +0,0 @@ -package test - -inline fun foo(x: Function0) { -} - -fun String.id(s: String = , vararg xs: Int): String { - return s -} - -fun test() { - foo(x = { // BLOCK - local fun String.id() { - receiver.id() - } - - "Fail"::id - }) -} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.kt b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.kt index 3282a8c221f..fa793b3f412 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.kt +++ b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL package test inline fun foo(x: () -> Unit) {} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt index 7e9899ad259..1ba9596fc19 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt @@ -112,9 +112,10 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt 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 ' type=kotlin.Int origin=null - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .test1.withVararg' type=kotlin.Int origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.Int declared in ' type=kotlin.Int origin=null + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .test1.withVararg' type=kotlin.Int origin=null FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .test1' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun withVararg (vararg xs: kotlin.Int): kotlin.Int declared in CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=PLUSEQ $receiver: GET_VAR 'val tmp_0: .A declared in .test1' type=.A origin=null @@ -136,9 +137,10 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt 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 ' type=kotlin.Int origin=null - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .test2.withVararg' type=kotlin.Int origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.Int declared in ' type=kotlin.Int origin=null + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .test2.withVararg' type=kotlin.Int origin=null FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .test2' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun withVararg (vararg xs: kotlin.Int): kotlin.Int declared in CALL 'public final fun set (i: .IFoo2, newValue: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=PLUSEQ $receiver: GET_VAR 'val tmp_2: .B declared in .test2' type=.B origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt index fbca948c6a8..80ecc198ca7 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt @@ -47,7 +47,7 @@ fun test1() { val tmp_0: A = A val tmp_1: Function1 = { // BLOCK local fun withVararg(p0: Int) { - withVararg(xs = [p0]) + withVararg(xs = [p0]) /*~> Unit */ } ::withVararg @@ -61,7 +61,7 @@ fun test2() { val tmp_2: B = B val tmp_3: Function1 = { // BLOCK local fun withVararg(p0: Int) { - withVararg(xs = [p0]) + withVararg(xs = [p0]) /*~> Unit */ } ::withVararg diff --git a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.fir.ir.txt deleted file mode 100644 index 9449a11cc3a..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.fir.ir.txt +++ /dev/null @@ -1,145 +0,0 @@ -FILE fqName: fileName:/suspendConversion.kt - FUN name:useSuspend visibility:public modality:FINAL <> (fn:kotlin.coroutines.SuspendFunction0) returnType:kotlin.Unit - VALUE_PARAMETER name:fn index:0 type:kotlin.coroutines.SuspendFunction0 - BLOCK_BODY - FUN name:useSuspendNullable visibility:public modality:FINAL <> (fn:kotlin.coroutines.SuspendFunction0?) returnType:kotlin.Unit - VALUE_PARAMETER name:fn index:0 type:kotlin.coroutines.SuspendFunction0? - BLOCK_BODY - FUN name:useSuspendNestedNullable visibility:public modality:FINAL <> (fn:kotlin.coroutines.SuspendFunction0?) returnType:kotlin.Unit - VALUE_PARAMETER name:fn index:0 type:kotlin.coroutines.SuspendFunction0? - BLOCK_BODY - FUN name:useSuspendInt visibility:public modality:FINAL <> (fn:kotlin.coroutines.SuspendFunction1) returnType:kotlin.Unit - VALUE_PARAMETER name:fn index:0 type:kotlin.coroutines.SuspendFunction1 - BLOCK_BODY - FUN name:foo0 visibility:public modality:FINAL <> () returnType:kotlin.Unit [suspend] - BLOCK_BODY - FUN name:foo1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - FUN name:fooInt visibility:public modality:FINAL <> (x:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER name:x index:0 type:kotlin.Int - BLOCK_BODY - FUN name:foo2 visibility:public modality:FINAL <> (xs:kotlin.IntArray) returnType:kotlin.Unit - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - BLOCK_BODY - FUN name:foo3 visibility:public modality:FINAL <> () returnType:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun foo3 (): kotlin.Int declared in ' - CONST Int type=kotlin.Int value=42 - FUN name:foo4 visibility:public modality:FINAL <> (i:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER name:i index:0 type:kotlin.Int - EXPRESSION_BODY - CONST Int type=kotlin.Int value=42 - BLOCK_BODY - CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C - CONSTRUCTOR visibility:public <> () returnType:.C [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:bar visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.C - BLOCK_BODY - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:testLambda visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun useSuspend (fn: kotlin.coroutines.SuspendFunction0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend] - BLOCK_BODY - CALL 'public final fun foo1 (): kotlin.Unit declared in ' type=kotlin.Unit origin=null - FUN name:testNoCoversion visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun useSuspend (fn: kotlin.coroutines.SuspendFunction0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUNCTION_REFERENCE 'public final fun foo0 (): kotlin.Unit declared in ' type=kotlin.reflect.KSuspendFunction0 origin=null reflectionTarget= - FUN name:testSuspendPlain visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun useSuspend (fn: kotlin.coroutines.SuspendFunction0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo1 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend] - BLOCK_BODY - CALL 'public final fun foo1 (): kotlin.Unit declared in ' type=kotlin.Unit origin=null - FUNCTION_REFERENCE 'local final fun foo1 (): kotlin.Unit declared in .testSuspendPlain' type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo1 (): kotlin.Unit declared in - FUN name:testSuspendWithArgs visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun useSuspendInt (fn: kotlin.coroutines.SuspendFunction1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.coroutines.SuspendFunction1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fooInt visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit [suspend] - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - CALL 'public final fun fooInt (x: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=null - x: GET_VAR 'p0: kotlin.Int declared in .testSuspendWithArgs.fooInt' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun fooInt (p0: kotlin.Int): kotlin.Unit declared in .testSuspendWithArgs' type=kotlin.coroutines.SuspendFunction1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun fooInt (x: kotlin.Int): kotlin.Unit declared in - FUN name:testWithVararg visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun useSuspend (fn: kotlin.coroutines.SuspendFunction0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo2 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend] - BLOCK_BODY - CALL 'public final fun foo2 (vararg xs: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=null - FUNCTION_REFERENCE 'local final fun foo2 (): kotlin.Unit declared in .testWithVararg' type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo2 (vararg xs: kotlin.Int): kotlin.Unit declared in - FUN name:testWithVarargMapped visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun useSuspendInt (fn: kotlin.coroutines.SuspendFunction1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.coroutines.SuspendFunction1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo2 visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit [suspend] - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - CALL 'public final fun foo2 (vararg xs: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=null - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .testWithVarargMapped.foo2' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun foo2 (p0: kotlin.Int): kotlin.Unit declared in .testWithVarargMapped' type=kotlin.coroutines.SuspendFunction1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo2 (vararg xs: kotlin.Int): kotlin.Unit declared in - FUN name:testWithCoercionToUnit visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun useSuspend (fn: kotlin.coroutines.SuspendFunction0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo3 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend] - BLOCK_BODY - CALL 'public final fun foo3 (): kotlin.Int declared in ' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun foo3 (): kotlin.Unit declared in .testWithCoercionToUnit' type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo3 (): kotlin.Int declared in - FUN name:testWithDefaults visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun useSuspend (fn: kotlin.coroutines.SuspendFunction0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo4 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend] - BLOCK_BODY - CALL 'public final fun foo4 (i: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=null - FUNCTION_REFERENCE 'local final fun foo4 (): kotlin.Unit declared in .testWithDefaults' type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo4 (i: kotlin.Int): kotlin.Unit declared in - FUN name:testWithBoundReceiver visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun useSuspend (fn: kotlin.coroutines.SuspendFunction0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:bar visibility:local modality:FINAL <> ($receiver:.C) returnType:kotlin.Unit [suspend] - $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.C - BLOCK_BODY - CALL 'public final fun bar (): kotlin.Unit declared in .C' type=kotlin.Unit origin=null - $this: GET_VAR 'receiver: .C declared in .testWithBoundReceiver.bar' type=.C origin=ADAPTED_FUNCTION_REFERENCE - FUNCTION_REFERENCE 'local final fun bar (): kotlin.Unit declared in .testWithBoundReceiver' type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun bar (): kotlin.Unit declared in .C - $receiver: CONSTRUCTOR_CALL 'public constructor () declared in .C' type=.C origin=null - FUN name:testNullableParam visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun useSuspendNullable (fn: kotlin.coroutines.SuspendFunction0?): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo1 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend] - BLOCK_BODY - CALL 'public final fun foo1 (): kotlin.Unit declared in ' type=kotlin.Unit origin=null - FUNCTION_REFERENCE 'local final fun foo1 (): kotlin.Unit declared in .testNullableParam' type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo1 (): kotlin.Unit declared in - FUN name:testNestedNullableParam visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun useSuspendNestedNullable (fn: kotlin.coroutines.SuspendFunction0?): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo1 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend] - BLOCK_BODY - CALL 'public final fun foo1 (): kotlin.Unit declared in ' type=kotlin.Unit origin=null - FUNCTION_REFERENCE 'local final fun foo1 (): kotlin.Unit declared in .testNestedNullableParam' type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo1 (): kotlin.Unit declared in diff --git a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.fir.kt.txt deleted file mode 100644 index d2d316261a8..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.fir.kt.txt +++ /dev/null @@ -1,144 +0,0 @@ -fun useSuspend(fn: SuspendFunction0) { -} - -fun useSuspendNullable(fn: SuspendFunction0?) { -} - -fun useSuspendNestedNullable(fn: SuspendFunction0?) { -} - -fun useSuspendInt(fn: SuspendFunction1) { -} - -suspend fun foo0() { -} - -fun foo1() { -} - -fun fooInt(x: Int) { -} - -fun foo2(vararg xs: Int) { -} - -fun foo3(): Int { - return 42 -} - -fun foo4(i: Int = 42) { -} - -class C { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - fun bar() { - } - -} - -fun testLambda() { - useSuspend(fn = local suspend fun () { - foo1() - } -) -} - -fun testNoCoversion() { - useSuspend(fn = ::foo0) -} - -fun testSuspendPlain() { - useSuspend(fn = { // BLOCK - local suspend fun foo1() { - foo1() - } - - ::foo1 - }) -} - -fun testSuspendWithArgs() { - useSuspendInt(fn = { // BLOCK - local suspend fun fooInt(p0: Int) { - fooInt(x = p0) - } - - ::fooInt - }) -} - -fun testWithVararg() { - useSuspend(fn = { // BLOCK - local suspend fun foo2() { - foo2() - } - - ::foo2 - }) -} - -fun testWithVarargMapped() { - useSuspendInt(fn = { // BLOCK - local suspend fun foo2(p0: Int) { - foo2(xs = [p0]) - } - - ::foo2 - }) -} - -fun testWithCoercionToUnit() { - useSuspend(fn = { // BLOCK - local suspend fun foo3() { - foo3() - } - - ::foo3 - }) -} - -fun testWithDefaults() { - useSuspend(fn = { // BLOCK - local suspend fun foo4() { - foo4() - } - - ::foo4 - }) -} - -fun testWithBoundReceiver() { - useSuspend(fn = { // BLOCK - local suspend fun C.bar() { - receiver.bar() - } - - C()::bar - }) -} - -fun testNullableParam() { - useSuspendNullable(fn = { // BLOCK - local suspend fun foo1() { - foo1() - } - - ::foo1 - }) -} - -fun testNestedNullableParam() { - useSuspendNestedNullable(fn = { // BLOCK - local suspend fun foo1() { - foo1() - } - - ::foo1 - }) -} - diff --git a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.kt b/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.kt index 07b374f0faf..fab20d665a0 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.kt +++ b/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +SuspendConversion fun useSuspend(fn: suspend () -> Unit) {} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.ir.txt deleted file mode 100644 index 379838b11e1..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.ir.txt +++ /dev/null @@ -1,101 +0,0 @@ -FILE fqName: fileName:/unboundMemberReferenceWithAdaptedArguments.kt - FUN name:use1 visibility:public modality:FINAL <> (fn:kotlin.Function2<.A, kotlin.Int, kotlin.Unit>) returnType:kotlin.Unit - VALUE_PARAMETER name:fn index:0 type:kotlin.Function2<.A, kotlin.Int, kotlin.Unit> - BLOCK_BODY - FUN name:use2 visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Unit - VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 - BLOCK_BODY - CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A - CONSTRUCTOR visibility:public <> () returnType:.A [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]' - FUN name:foo visibility:public modality:OPEN <> ($this:.A, xs:kotlin.IntArray) returnType:kotlin.Int - $this: VALUE_PARAMETER name: type:.A - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .A' - CONST Int type=kotlin.Int value=1 - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS OBJECT name:Obj modality:FINAL visibility:public superTypes:[.A] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Obj - CONSTRUCTOR visibility:private <> () returnType:.Obj [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .A' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Obj modality:FINAL visibility:public superTypes:[.A]' - FUN name:foo visibility:public modality:OPEN <> ($this:.Obj, xs:kotlin.IntArray) returnType:kotlin.Int - overridden: - public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .A - $this: VALUE_PARAMETER name: type:.Obj - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .Obj' - CONST Int type=kotlin.Int value=1 - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .A - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in .A - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in .A - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:testUnbound visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun use1 (fn: kotlin.Function2<.A, kotlin.Int, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function2<.A, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo visibility:local modality:FINAL <> (p0:.A, p1:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:.A - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p1 index:1 type:kotlin.Int - BLOCK_BODY - CALL 'public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .A' type=kotlin.Int origin=null - $this: GET_VAR 'p0: .A declared in .testUnbound.foo' type=.A origin=null - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p1: kotlin.Int declared in .testUnbound.foo' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun foo (p0: .A, p1: kotlin.Int): kotlin.Unit declared in .testUnbound' type=kotlin.Function2<.A, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .A - FUN name:testBound visibility:public modality:FINAL <> (a:.A) returnType:kotlin.Unit - VALUE_PARAMETER name:a index:0 type:.A - BLOCK_BODY - CALL 'public final fun use2 (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo visibility:local modality:FINAL <> ($receiver:.A, p0:kotlin.Int) returnType:kotlin.Unit - $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.A - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - CALL 'public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .A' type=kotlin.Int origin=null - $this: GET_VAR 'receiver: .A declared in .testBound.foo' type=.A origin=ADAPTED_FUNCTION_REFERENCE - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .testBound.foo' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun foo (p0: kotlin.Int): kotlin.Unit declared in .testBound' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .A - $receiver: GET_VAR 'a: .A declared in .testBound' type=.A origin=null - FUN name:testObject visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun use2 (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo visibility:local modality:FINAL <> ($receiver:.Obj, p0:kotlin.Int) returnType:kotlin.Unit - $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Obj - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - CALL 'public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .Obj' type=kotlin.Int origin=null - $this: GET_VAR 'receiver: .Obj declared in .testObject.foo' type=.Obj origin=ADAPTED_FUNCTION_REFERENCE - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .testObject.foo' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun foo (p0: kotlin.Int): kotlin.Unit declared in .testObject' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .Obj - $receiver: GET_OBJECT 'CLASS OBJECT name:Obj modality:FINAL visibility:public superTypes:[.A]' type=.Obj diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.kt.txt deleted file mode 100644 index 0bc7d6bf318..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.kt.txt +++ /dev/null @@ -1,62 +0,0 @@ -fun use1(fn: Function2) { -} - -fun use2(fn: Function1) { -} - -open class A { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - open fun foo(vararg xs: Int): Int { - return 1 - } - -} - -object Obj : A { - private constructor() /* primary */ { - super/*A*/() - /* () */ - - } - - override fun foo(vararg xs: Int): Int { - return 1 - } - -} - -fun testUnbound() { - use1(fn = { // BLOCK - local fun foo(p0: A, p1: Int) { - p0.foo(xs = [p1]) - } - - ::foo - }) -} - -fun testBound(a: A) { - use2(fn = { // BLOCK - local fun A.foo(p0: Int) { - receiver.foo(xs = [p0]) - } - - a::foo - }) -} - -fun testObject() { - use2(fn = { // BLOCK - local fun Obj.foo(p0: Int) { - receiver.foo(xs = [p0]) - } - - Obj::foo - }) -} - diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt index 7bb7f2c9002..96f2e7c1b38 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt +++ b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun use1(fn: (A, Int) -> Unit) {} fun use2(fn: (Int) -> Unit) {} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.fir.ir.txt deleted file mode 100644 index c4363a6f4e6..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.fir.ir.txt +++ /dev/null @@ -1,39 +0,0 @@ -FILE fqName: fileName:/withAdaptationForSam.kt - CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IFoo - FUN name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo, i:kotlin.Int) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.IFoo - VALUE_PARAMETER name:i index:0 type:kotlin.Int - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:useFoo visibility:public modality:FINAL <> (foo:.IFoo) returnType:kotlin.Unit - VALUE_PARAMETER name:foo index:0 type:.IFoo - BLOCK_BODY - FUN name:withVararg visibility:public modality:FINAL <> (xs:kotlin.IntArray) returnType:kotlin.Int - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun withVararg (vararg xs: kotlin.Int): kotlin.Int declared in ' - CONST Int type=kotlin.Int value=42 - FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun useFoo (foo: .IFoo): kotlin.Unit declared in ' type=kotlin.Unit origin=null - foo: BLOCK type=.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 ' type=kotlin.Int origin=null - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .test.withVararg' type=kotlin.Int origin=null - TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo - FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .test' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun withVararg (vararg xs: kotlin.Int): kotlin.Int declared in diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.fir.kt.txt deleted file mode 100644 index 5b8387c229f..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.fir.kt.txt +++ /dev/null @@ -1,22 +0,0 @@ -fun interface IFoo { - abstract fun foo(i: Int) - -} - -fun useFoo(foo: IFoo) { -} - -fun withVararg(vararg xs: Int): Int { - return 42 -} - -fun test() { - useFoo(foo = { // BLOCK - local fun withVararg(p0: Int) { - withVararg(xs = [p0]) - } - - ::withVararg /*-> IFoo */ - }) -} - diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.kt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.kt index d70eb69a26c..3d07d2465bd 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.kt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun interface IFoo { fun foo(i: Int) } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.ir.txt deleted file mode 100644 index a7ff9f14acc..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.ir.txt +++ /dev/null @@ -1,137 +0,0 @@ -FILE fqName: fileName:/withAdaptedArguments.kt - FUN name:use visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.String - VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun use (fn: kotlin.Function1): kotlin.String declared in ' - CALL 'public abstract fun invoke (p1: P1 of kotlin.Function1): R of kotlin.Function1 declared in kotlin.Function1' type=kotlin.String origin=INVOKE - $this: GET_VAR 'fn: kotlin.Function1 declared in .use' type=kotlin.Function1 origin=VARIABLE_AS_FUNCTION - p1: CONST Int type=kotlin.Int value=1 - FUN name:use0 visibility:public modality:FINAL <> (fn:kotlin.Function0) returnType:kotlin.String - VALUE_PARAMETER name:fn index:0 type:kotlin.Function0 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun use0 (fn: kotlin.Function0): kotlin.String declared in ' - CALL 'public abstract fun invoke (): R of kotlin.Function0 declared in kotlin.Function0' type=kotlin.String origin=INVOKE - $this: GET_VAR 'fn: kotlin.Function0 declared in .use0' type=kotlin.Function0 origin=VARIABLE_AS_FUNCTION - FUN name:coerceToUnit visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Unit - VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 - BLOCK_BODY - FUN name:fnWithDefault visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.String - VALUE_PARAMETER name:a index:0 type:kotlin.Int - VALUE_PARAMETER name:b index:1 type:kotlin.Int - EXPRESSION_BODY - CONST Int type=kotlin.Int value=42 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' - CONST String type=kotlin.String value="abc" - FUN name:fnWithDefaults visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.String - VALUE_PARAMETER name:a index:0 type:kotlin.Int - EXPRESSION_BODY - CONST Int type=kotlin.Int value=1 - VALUE_PARAMETER name:b index:1 type:kotlin.Int - EXPRESSION_BODY - CONST Int type=kotlin.Int value=2 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun fnWithDefaults (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' - CONST String type=kotlin.String value="" - FUN name:fnWithVarargs visibility:public modality:FINAL <> (xs:kotlin.IntArray) returnType:kotlin.String - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun fnWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in ' - CONST String type=kotlin.String value="abc" - CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Host - CONSTRUCTOR visibility:private <> () returnType:.Host [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:importedObjectMemberWithVarargs visibility:public modality:FINAL <> ($this:.Host, xs:kotlin.IntArray) returnType:kotlin.String - $this: VALUE_PARAMETER name: type:.Host - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun importedObjectMemberWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in .Host' - CONST String type=kotlin.String value="abc" - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:testDefault visibility:public modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testDefault (): kotlin.String declared in ' - CALL 'public final fun use (fn: kotlin.Function1): kotlin.String declared in ' type=kotlin.String origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnWithDefault visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.String - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun fnWithDefault (p0: kotlin.Int): kotlin.String declared in .testDefault' - CALL 'public final fun fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.String origin=null - a: GET_VAR 'p0: kotlin.Int declared in .testDefault.fnWithDefault' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun fnWithDefault (p0: kotlin.Int): kotlin.String declared in .testDefault' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in - FUN name:testVararg visibility:public modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testVararg (): kotlin.String declared in ' - CALL 'public final fun use (fn: kotlin.Function1): kotlin.String declared in ' type=kotlin.String origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnWithVarargs visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.String - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun fnWithVarargs (p0: kotlin.Int): kotlin.String declared in .testVararg' - CALL 'public final fun fnWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in ' type=kotlin.String origin=null - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .testVararg.fnWithVarargs' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun fnWithVarargs (p0: kotlin.Int): kotlin.String declared in .testVararg' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun fnWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in - FUN name:testCoercionToUnit visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testCoercionToUnit (): kotlin.Unit declared in ' - CALL 'public final fun coerceToUnit (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnWithDefault 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 fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.String origin=null - a: GET_VAR 'p0: kotlin.Int declared in .testCoercionToUnit.fnWithDefault' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun fnWithDefault (p0: kotlin.Int): kotlin.Unit declared in .testCoercionToUnit' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in - FUN name:testImportedObjectMember visibility:public modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testImportedObjectMember (): kotlin.String declared in ' - CALL 'public final fun use (fn: kotlin.Function1): kotlin.String declared in ' type=kotlin.String origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:importedObjectMemberWithVarargs visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.Int) returnType:kotlin.String - $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Host - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun importedObjectMemberWithVarargs (p0: kotlin.Int): kotlin.String declared in .testImportedObjectMember' - CALL 'public final fun importedObjectMemberWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR 'receiver: .Host declared in .testImportedObjectMember.importedObjectMemberWithVarargs' type=.Host origin=ADAPTED_FUNCTION_REFERENCE - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .testImportedObjectMember.importedObjectMemberWithVarargs' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun importedObjectMemberWithVarargs (p0: kotlin.Int): kotlin.String declared in .testImportedObjectMember' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun importedObjectMemberWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in .Host - $receiver: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host - FUN name:testDefault0 visibility:public modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testDefault0 (): kotlin.String declared in ' - CALL 'public final fun use0 (fn: kotlin.Function0): kotlin.String declared in ' type=kotlin.String origin=null - fn: BLOCK type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnWithDefaults visibility:local modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun fnWithDefaults (): kotlin.String declared in .testDefault0' - CALL 'public final fun fnWithDefaults (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.String origin=null - FUNCTION_REFERENCE 'local final fun fnWithDefaults (): kotlin.String declared in .testDefault0' type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun fnWithDefaults (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in - FUN name:testVararg0 visibility:public modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testVararg0 (): kotlin.String declared in ' - CALL 'public final fun use0 (fn: kotlin.Function0): kotlin.String declared in ' type=kotlin.String origin=null - fn: BLOCK type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnWithVarargs visibility:local modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun fnWithVarargs (): kotlin.String declared in .testVararg0' - CALL 'public final fun fnWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in ' type=kotlin.String origin=null - FUNCTION_REFERENCE 'local final fun fnWithVarargs (): kotlin.String declared in .testVararg0' type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun fnWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.kt.txt deleted file mode 100644 index efd24aecbf8..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.kt.txt +++ /dev/null @@ -1,96 +0,0 @@ -fun use(fn: Function1): String { - return fn.invoke(p1 = 1) -} - -fun use0(fn: Function0): String { - return fn.invoke() -} - -fun coerceToUnit(fn: Function1) { -} - -fun fnWithDefault(a: Int, b: Int = 42): String { - return "abc" -} - -fun fnWithDefaults(a: Int = 1, b: Int = 2): String { - return "" -} - -fun fnWithVarargs(vararg xs: Int): String { - return "abc" -} - -object Host { - private constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - fun importedObjectMemberWithVarargs(vararg xs: Int): String { - return "abc" - } - -} - -fun testDefault(): String { - return use(fn = { // BLOCK - local fun fnWithDefault(p0: Int): String { - return fnWithDefault(a = p0) - } - - ::fnWithDefault - }) -} - -fun testVararg(): String { - return use(fn = { // BLOCK - local fun fnWithVarargs(p0: Int): String { - return fnWithVarargs(xs = [p0]) - } - - ::fnWithVarargs - }) -} - -fun testCoercionToUnit() { - return coerceToUnit(fn = { // BLOCK - local fun fnWithDefault(p0: Int) { - fnWithDefault(a = p0) - } - - ::fnWithDefault - }) -} - -fun testImportedObjectMember(): String { - return use(fn = { // BLOCK - local fun Host.importedObjectMemberWithVarargs(p0: Int): String { - return receiver.importedObjectMemberWithVarargs(xs = [p0]) - } - - Host::importedObjectMemberWithVarargs - }) -} - -fun testDefault0(): String { - return use0(fn = { // BLOCK - local fun fnWithDefaults(): String { - return fnWithDefaults() - } - - ::fnWithDefaults - }) -} - -fun testVararg0(): String { - return use0(fn = { // BLOCK - local fun fnWithVarargs(): String { - return fnWithVarargs() - } - - ::fnWithVarargs - }) -} - diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.kt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.kt index 6fafb13037a..951ea69b351 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.kt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL import Host.importedObjectMemberWithVarargs fun use(fn: (Int) -> String) = fn(1) diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.ir.txt deleted file mode 100644 index 139efeabaf2..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.ir.txt +++ /dev/null @@ -1,112 +0,0 @@ -FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt - FUN name:use visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Unit - VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 - BLOCK_BODY - CALL 'public abstract fun invoke (p1: P1 of kotlin.Function1): R of kotlin.Function1 declared in kotlin.Function1' type=kotlin.Unit origin=INVOKE - $this: GET_VAR 'fn: kotlin.Function1 declared in .use' type=kotlin.Function1 origin=VARIABLE_AS_FUNCTION - p1: CONST Int type=kotlin.Int value=1 - CLASS CLASS name:Host modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Host - CONSTRUCTOR visibility:public <> () returnType:.Host [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:withVararg visibility:public modality:FINAL <> ($this:.Host, xs:kotlin.IntArray) returnType:kotlin.String - $this: VALUE_PARAMETER name: type:.Host - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host' - CONST String type=kotlin.String value="" - FUN name:testImplicitThis visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.Host - BLOCK_BODY - CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.Int) returnType:kotlin.Unit - $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Host - 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.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR 'receiver: .Host declared in .Host.testImplicitThis.withVararg' type=.Host origin=ADAPTED_FUNCTION_REFERENCE - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .Host.testImplicitThis.withVararg' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testImplicitThis' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host - $receiver: GET_VAR ': .Host declared in .Host.testImplicitThis' type=.Host origin=null - FUN name:testBoundReceiverLocalVal visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.Host - BLOCK_BODY - VAR name:h type:.Host [val] - CONSTRUCTOR_CALL 'public constructor () declared in .Host' type=.Host origin=null - CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.Int) returnType:kotlin.Unit - $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Host - 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.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR 'receiver: .Host declared in .Host.testBoundReceiverLocalVal.withVararg' type=.Host origin=ADAPTED_FUNCTION_REFERENCE - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .Host.testBoundReceiverLocalVal.withVararg' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverLocalVal' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host - $receiver: GET_VAR 'val h: .Host declared in .Host.testBoundReceiverLocalVal' type=.Host origin=null - FUN name:testBoundReceiverLocalVar visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.Host - BLOCK_BODY - VAR name:h type:.Host [var] - CONSTRUCTOR_CALL 'public constructor () declared in .Host' type=.Host origin=null - CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.Int) returnType:kotlin.Unit - $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Host - 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.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR 'receiver: .Host declared in .Host.testBoundReceiverLocalVar.withVararg' type=.Host origin=ADAPTED_FUNCTION_REFERENCE - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .Host.testBoundReceiverLocalVar.withVararg' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverLocalVar' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host - $receiver: GET_VAR 'var h: .Host declared in .Host.testBoundReceiverLocalVar' type=.Host origin=null - FUN name:testBoundReceiverParameter visibility:public modality:FINAL <> ($this:.Host, h:.Host) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.Host - VALUE_PARAMETER name:h index:0 type:.Host - BLOCK_BODY - CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.Int) returnType:kotlin.Unit - $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Host - 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.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR 'receiver: .Host declared in .Host.testBoundReceiverParameter.withVararg' type=.Host origin=ADAPTED_FUNCTION_REFERENCE - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .Host.testBoundReceiverParameter.withVararg' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverParameter' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host - $receiver: GET_VAR 'h: .Host declared in .Host.testBoundReceiverParameter' type=.Host origin=null - FUN name:testBoundReceiverExpression visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.Host - BLOCK_BODY - CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.Int) returnType:kotlin.Unit - $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Host - 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.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR 'receiver: .Host declared in .Host.testBoundReceiverExpression.withVararg' type=.Host origin=ADAPTED_FUNCTION_REFERENCE - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .Host.testBoundReceiverExpression.withVararg' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverExpression' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host - $receiver: CONSTRUCTOR_CALL 'public constructor () declared in .Host' type=.Host origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.kt.txt deleted file mode 100644 index ccdc8454781..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.kt.txt +++ /dev/null @@ -1,68 +0,0 @@ -fun use(fn: Function1) { - fn.invoke(p1 = 1) -} - -class Host { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - fun withVararg(vararg xs: Int): String { - return "" - } - - fun testImplicitThis() { - use(fn = { // BLOCK - local fun Host.withVararg(p0: Int) { - receiver.withVararg(xs = [p0]) - } - - ::withVararg - }) - } - - fun testBoundReceiverLocalVal() { - val h: Host = Host() - use(fn = { // BLOCK - local fun Host.withVararg(p0: Int) { - receiver.withVararg(xs = [p0]) - } - - h::withVararg - }) - } - - fun testBoundReceiverLocalVar() { - var h: Host = Host() - use(fn = { // BLOCK - local fun Host.withVararg(p0: Int) { - receiver.withVararg(xs = [p0]) - } - - h::withVararg - }) - } - - fun testBoundReceiverParameter(h: Host) { - use(fn = { // BLOCK - local fun Host.withVararg(p0: Int) { - receiver.withVararg(xs = [p0]) - } - - h::withVararg - }) - } - - fun testBoundReceiverExpression() { - use(fn = { // BLOCK - local fun Host.withVararg(p0: Int) { - receiver.withVararg(xs = [p0]) - } - - Host()::withVararg - }) - } - -} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.kt b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.kt index 2758838496b..38562178245 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.kt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun use(fn: (Int) -> Unit) { fn(1) } class Host { diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.fir.ir.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.fir.ir.txt index 4744d24c44b..c4eddb14bf7 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.fir.ir.txt @@ -69,8 +69,9 @@ FILE fqName: fileName:/samConversionInVarargs.kt 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 ' type=kotlin.String origin=null - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .testAdaptedCR.withVarargOfInt' type=kotlin.Int origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun withVarargOfInt (vararg xs: kotlin.Int): kotlin.String declared in ' type=kotlin.String origin=null + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .testAdaptedCR.withVarargOfInt' type=kotlin.Int origin=null TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo FUNCTION_REFERENCE 'local final fun withVarargOfInt (p0: kotlin.Int): kotlin.Unit declared in .testAdaptedCR' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun withVarargOfInt (vararg xs: kotlin.Int): kotlin.String declared in diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.fir.kt.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.fir.kt.txt index ab0b4ee240a..455accad276 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.fir.kt.txt @@ -33,7 +33,7 @@ fun withVarargOfInt(vararg xs: Int): String { fun testAdaptedCR() { useVararg(foos = [{ // BLOCK local fun withVarargOfInt(p0: Int) { - withVarargOfInt(xs = [p0]) + withVarargOfInt(xs = [p0]) /*~> Unit */ } ::withVarargOfInt /*-> IFoo */ diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.ir.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.ir.txt deleted file mode 100644 index dc4b9912216..00000000000 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.ir.txt +++ /dev/null @@ -1,56 +0,0 @@ -FILE fqName: fileName:/samConversionOnCallableReference.kt - CLASS INTERFACE name:KRunnable modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.KRunnable - FUN name:run visibility:public modality:ABSTRACT <> ($this:.KRunnable) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.KRunnable - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:foo0 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - FUN name:foo1 visibility:public modality:FINAL <> (xs:kotlin.IntArray) returnType:kotlin.Int - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in ' - CONST Int type=kotlin.Int value=1 - FUN name:use visibility:public modality:FINAL <> (r:.KRunnable) returnType:kotlin.Unit - VALUE_PARAMETER name:r index:0 type:.KRunnable - BLOCK_BODY - FUN name:testSamConstructor visibility:public modality:FINAL <> () returnType:.KRunnable - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testSamConstructor (): .KRunnable declared in ' - TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - FUNCTION_REFERENCE 'public final fun foo0 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= - FUN name:testSamCosntructorOnAdapted visibility:public modality:FINAL <> () returnType:.KRunnable - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testSamCosntructorOnAdapted (): .KRunnable declared in ' - TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - BLOCK type=kotlin.Function0 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 ' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun foo1 (): kotlin.Unit declared in .testSamCosntructorOnAdapted' type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in - FUN name:testSamConversion visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun use (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r: TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - FUNCTION_REFERENCE 'public final fun foo0 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= - FUN name:testSamConversionOnAdapted visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun use (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r: BLOCK type=.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 ' type=kotlin.Int origin=null - TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - FUNCTION_REFERENCE 'local final fun foo1 (): kotlin.Unit declared in .testSamConversionOnAdapted' type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.kt.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.kt.txt deleted file mode 100644 index ce6ace75d9e..00000000000 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.kt.txt +++ /dev/null @@ -1,43 +0,0 @@ -fun interface KRunnable { - abstract fun run() - -} - -fun foo0() { -} - -fun foo1(vararg xs: Int): Int { - return 1 -} - -fun use(r: KRunnable) { -} - -fun testSamConstructor(): KRunnable { - return ::foo0 /*-> KRunnable */ -} - -fun testSamCosntructorOnAdapted(): KRunnable { - return { // BLOCK - local fun foo1() { - foo1() - } - - ::foo1 - } /*-> KRunnable */ -} - -fun testSamConversion() { - use(r = ::foo0 /*-> KRunnable */) -} - -fun testSamConversionOnAdapted() { - use(r = { // BLOCK - local fun foo1() { - foo1() - } - - ::foo1 /*-> KRunnable */ - }) -} - diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt index 00d35747025..44c60fda4dd 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun interface KRunnable { fun run() } diff --git a/compiler/testData/ir/irText/expressions/suspendConversionWithFunInterfaces.fir.ir.txt b/compiler/testData/ir/irText/expressions/suspendConversionWithFunInterfaces.fir.ir.txt index e9c9c166b21..ef9f00c9f12 100644 --- a/compiler/testData/ir/irText/expressions/suspendConversionWithFunInterfaces.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/suspendConversionWithFunInterfaces.fir.ir.txt @@ -50,7 +50,8 @@ FILE fqName: fileName:/suspendConversionWithFunInterfaces.kt s: BLOCK type=.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 ' type=kotlin.Int origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun bar2 (s: kotlin.String): kotlin.Int declared in ' type=kotlin.Int origin=null TYPE_OP type=.SuspendRunnable origin=SAM_CONVERSION typeOperand=.SuspendRunnable FUNCTION_REFERENCE 'local final fun bar2 (): kotlin.Unit declared in .box' type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun bar2 (s: kotlin.String): kotlin.Int declared in CALL 'public final fun foo1 (s: .SuspendRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null