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 bd525133d8a..e8848451938 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 @@ -161,18 +161,21 @@ internal class AdapterGenerator( } } - val boundReceiver = boundDispatchReceiver ?: boundExtensionReceiver - if (boundReceiver == null) { - IrFunctionExpressionImpl(startOffset, endOffset, type, irAdapterFunction, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE) - } else { - val irAdapterRef = IrFunctionReferenceImpl( - startOffset, endOffset, type, irAdapterFunction.symbol, irAdapterFunction.typeParameters.size, - irAdapterFunction.valueParameters.size, null, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE - ) - IrBlockImpl(startOffset, endOffset, type, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE).apply { - statements.add(irAdapterFunction) - statements.add(irAdapterRef.apply { extensionReceiver = boundReceiver }) - } + require(irAdapterFunction.typeParameters.isEmpty()) { + "Internal error: function adapter ${irAdapterFunction.symbol} " + + "has unexpected type parameters: ${irAdapterFunction.typeParameters.map { it.symbol }}\n" + + "They should already be used to determine exact return type and value parameters types" + } + val irAdapterRef = IrFunctionReferenceImpl( + startOffset, endOffset, type, irAdapterFunction.symbol, typeArgumentsCount = 0, + irAdapterFunction.valueParameters.size, null, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE + ).apply { + extensionReceiver = boundDispatchReceiver ?: boundExtensionReceiver + reflectionTarget = adaptee.symbol + } + IrBlockImpl(startOffset, endOffset, type, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE).apply { + statements.add(irAdapterFunction) + statements.add(irAdapterRef) } } } diff --git a/compiler/testData/codegen/box/callableReference/adaptedReferences/suspendUnitConversion.kt b/compiler/testData/codegen/box/callableReference/adaptedReferences/suspendUnitConversion.kt index 47e501a08d7..e6f40945ca1 100644 --- a/compiler/testData/codegen/box/callableReference/adaptedReferences/suspendUnitConversion.kt +++ b/compiler/testData/codegen/box/callableReference/adaptedReferences/suspendUnitConversion.kt @@ -1,5 +1,7 @@ // WITH_COROUTINES // WITH_STDLIB +// KT-60700 +// IGNORE_BACKEND: WASM import helpers.* import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* diff --git a/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.ir.txt index 00abbdbd139..91002acef8d 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.ir.txt @@ -44,7 +44,7 @@ FILE fqName: fileName:/adaptedExtensionFunctions.kt FUN name:testExtensionVararg visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun use (f: @[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - f: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE + f: BLOCK type=@[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:extensionVararg visibility:local modality:FINAL <> (p0:.C, p1:kotlin.Int) returnType:kotlin.Unit VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:.C VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p1 index:1 type:kotlin.Int @@ -52,10 +52,11 @@ FILE fqName: fileName:/adaptedExtensionFunctions.kt CALL 'public final fun extensionVararg (i: kotlin.Int, vararg s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'p0: .C declared in .testExtensionVararg.extensionVararg' type=.C origin=null i: GET_VAR 'p1: kotlin.Int declared in .testExtensionVararg.extensionVararg' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun extensionVararg (p0: .C, p1: kotlin.Int): kotlin.Unit declared in .testExtensionVararg' type=@[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun extensionVararg (i: kotlin.Int, vararg s: kotlin.String): kotlin.Unit declared in FUN name:testExtensionDefault visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun use (f: @[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - f: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE + f: BLOCK type=@[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:extensionDefault visibility:local modality:FINAL <> (p0:.C, p1:kotlin.Int) returnType:kotlin.Unit VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:.C VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p1 index:1 type:kotlin.Int @@ -63,10 +64,11 @@ FILE fqName: fileName:/adaptedExtensionFunctions.kt CALL 'public final fun extensionDefault (i: kotlin.Int, s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'p0: .C declared in .testExtensionDefault.extensionDefault' type=.C origin=null i: GET_VAR 'p1: kotlin.Int declared in .testExtensionDefault.extensionDefault' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun extensionDefault (p0: .C, p1: kotlin.Int): kotlin.Unit declared in .testExtensionDefault' type=@[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun extensionDefault (i: kotlin.Int, s: kotlin.String): kotlin.Unit declared in FUN name:testExtensionBoth visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun use (f: @[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - f: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE + f: BLOCK type=@[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:extensionBoth visibility:local modality:FINAL <> (p0:.C, p1:kotlin.Int) returnType:kotlin.Unit VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:.C VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p1 index:1 type:kotlin.Int @@ -74,3 +76,4 @@ FILE fqName: fileName:/adaptedExtensionFunctions.kt CALL 'public final fun extensionBoth (i: kotlin.Int, s: kotlin.String, vararg t: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'p0: .C declared in .testExtensionBoth.extensionBoth' type=.C origin=null i: GET_VAR 'p1: kotlin.Int declared in .testExtensionBoth.extensionBoth' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun extensionBoth (p0: .C, p1: kotlin.Int): kotlin.Unit declared in .testExtensionBoth' type=@[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun extensionBoth (i: kotlin.Int, s: kotlin.String, vararg t: kotlin.String): kotlin.Unit declared in diff --git a/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.kt.txt index b6f65c65d60..b28c2fbf482 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.kt.txt @@ -20,22 +20,32 @@ fun C.extensionBoth(i: Int, s: String = "", vararg t: String) { } fun testExtensionVararg() { - use(f = local fun extensionVararg(p0: C, p1: Int) { - p0.extensionVararg(i = p1) - } -) + use(f = { // BLOCK + local fun extensionVararg(p0: C, p1: Int) { + p0.extensionVararg(i = p1) + } + + ::extensionVararg + }) } fun testExtensionDefault() { - use(f = local fun extensionDefault(p0: C, p1: Int) { - p0.extensionDefault(i = p1) - } -) + use(f = { // BLOCK + local fun extensionDefault(p0: C, p1: Int) { + p0.extensionDefault(i = p1) + } + + ::extensionDefault + }) } fun testExtensionBoth() { - use(f = local fun extensionBoth(p0: C, p1: Int) { - p0.extensionBoth(i = p1) - } -) + use(f = { // BLOCK + local fun extensionBoth(p0: C, p1: Int) { + p0.extensionBoth(i = p1) + } + + ::extensionBoth + }) } + diff --git a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.fir.ir.txt index cd6c5237784..8f1ea9bbc99 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.fir.ir.txt @@ -23,36 +23,40 @@ FILE fqName: fileName:/adaptedWithCoercionToUnit.kt 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: FUN_EXPR type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE + 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: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + 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: FUN_EXPR type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE + 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: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + 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 index 5786451f5dd..16cbf9acca6 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.fir.kt.txt @@ -17,29 +17,42 @@ fun fnv(vararg xs: Int): Int { } fun test0() { - return useUnit0(fn = local fun fn0() { - fn0() - } -) + return useUnit0(fn = { // BLOCK + local fun fn0() { + fn0() + } + + ::fn0 + }) } fun test1() { - return useUnit1(fn = local fun fn1(p0: Int) { - fn1(x = p0) - } -) + return useUnit1(fn = { // BLOCK + local fun fn1(p0: Int) { + fn1(x = p0) + } + + ::fn1 + }) } fun testV0() { - return useUnit0(fn = local fun fnv() { - fnv() - } -) + return useUnit0(fn = { // BLOCK + local fun fnv() { + fnv() + } + + ::fnv + }) } fun testV1() { - return useUnit1(fn = local fun fnv(p0: Int) { - fnv(xs = [p0]) - } -) + return useUnit1(fn = { // BLOCK + local fun fnv(p0: Int) { + fnv(xs = [p0]) + } + + ::fnv + }) } + diff --git a/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.ir.txt index b053334e7a9..cf757bec163 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.ir.txt @@ -20,5 +20,5 @@ FILE fqName:test fileName:/boundInlineAdaptedReference.kt 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=null + 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/caoWithAdaptationForSam.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt index ef571395c1d..be00541a0a5 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt @@ -108,13 +108,14 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.A [val] GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Function1 [val] - FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + BLOCK type=kotlin.Function1 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 .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=null $receiver: GET_VAR 'val tmp_0: .A declared in .test1' type=.A origin=null i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo @@ -131,13 +132,14 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.B [val] GET_OBJECT 'CLASS OBJECT name:B modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.B VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Function1 [val] - FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + BLOCK type=kotlin.Function1 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 .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=null $receiver: GET_VAR 'val tmp_2: .B declared in .test2' type=.B origin=null i: TYPE_OP type=.IFoo2 origin=SAM_CONVERSION typeOperand=.IFoo2 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 f594271cfd8..4b1d542b844 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt @@ -46,10 +46,13 @@ fun withVararg(vararg xs: Int): Int { fun test1() { { // BLOCK val : A = A - val : Function1 = local fun withVararg(p0: Int) { - withVararg(xs = [p0]) - } + val : Function1 = { // BLOCK + local fun withVararg(p0: Int) { + withVararg(xs = [p0]) + } + ::withVararg + } .set(i = /*-> IFoo */, newValue = .get(i = /*-> IFoo */).plus(other = 1)) } } @@ -57,10 +60,13 @@ fun test1() { fun test2() { { // BLOCK val : B = B - val : Function1 = local fun withVararg(p0: Int) { - withVararg(xs = [p0]) - } + val : Function1 = { // BLOCK + local fun withVararg(p0: Int) { + withVararg(xs = [p0]) + } + ::withVararg + } .set(i = /*-> IFoo2 */, newValue = .get(i = /*-> IFoo */).plus(other = 1)) } } @@ -103,3 +109,4 @@ fun test6(a: Any) { .set(i = , newValue = .get(i = ).plus(other = 1)) } } + diff --git a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.ir.txt deleted file mode 100644 index e2f3fa40714..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.ir.txt +++ /dev/null @@ -1,113 +0,0 @@ -FILE fqName: fileName:/constructorWithAdaptedArguments.kt - FUN name:use visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Any - VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun use (fn: kotlin.Function1): kotlin.Any declared in ' - CALL 'public abstract fun invoke (p1: P1 of kotlin.Function1): R of kotlin.Function1 declared in kotlin.Function1' type=kotlin.Any 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=42 - CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C - CONSTRUCTOR visibility:public <> (xs:kotlin.IntArray) returnType:.C [primary] - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - 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 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 CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Outer - CONSTRUCTOR visibility:public <> () returnType:.Outer [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any]' - CLASS CLASS name:Inner modality:FINAL visibility:public [inner] superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Outer.Inner - CONSTRUCTOR visibility:public <> ($this:.Outer, xs:kotlin.IntArray) returnType:.Outer.Inner [primary] - $outer: VALUE_PARAMETER name: type:.Outer - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Inner modality:FINAL visibility:public [inner] superTypes:[kotlin.Any]' - 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 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:testConstructor visibility:public modality:FINAL <> () returnType:kotlin.Any - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testConstructor (): kotlin.Any declared in ' - CALL 'public final fun use (fn: kotlin.Function1): kotlin.Any declared in ' type=kotlin.Any origin=null - fn: FUN_EXPR type=kotlin.Function1.C> origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:.C - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (p0: kotlin.Int): .C declared in .testConstructor' - CONSTRUCTOR_CALL 'public constructor (vararg xs: kotlin.Int) declared in .C' type=.C origin=null - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .testConstructor.' type=kotlin.Int origin=null - FUN name:testInnerClassConstructor visibility:public modality:FINAL <> (outer:.Outer) returnType:kotlin.Any - VALUE_PARAMETER name:outer index:0 type:.Outer - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testInnerClassConstructor (outer: .Outer): kotlin.Any declared in ' - CALL 'public final fun use (fn: kotlin.Function1): kotlin.Any declared in ' type=kotlin.Any origin=null - fn: BLOCK type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> ($receiver:.Outer, p0:kotlin.Int) returnType:.Outer.Inner - $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Outer - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructor' - CONSTRUCTOR_CALL 'public constructor (vararg xs: kotlin.Int) declared in .Outer.Inner' type=.Outer.Inner origin=null - $outer: GET_VAR 'receiver: .Outer declared in .testInnerClassConstructor.' type=.Outer origin=ADAPTED_FUNCTION_REFERENCE - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .testInnerClassConstructor.' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructor' type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null - $receiver: GET_VAR 'outer: .Outer declared in .testInnerClassConstructor' type=.Outer origin=null - FUN name:testInnerClassConstructorCapturingOuter visibility:public modality:FINAL <> () returnType:kotlin.Any - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testInnerClassConstructorCapturingOuter (): kotlin.Any declared in ' - CALL 'public final fun use (fn: kotlin.Function1): kotlin.Any declared in ' type=kotlin.Any origin=null - fn: BLOCK type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> ($receiver:.Outer, p0:kotlin.Int) returnType:.Outer.Inner - $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Outer - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructorCapturingOuter' - CONSTRUCTOR_CALL 'public constructor (vararg xs: kotlin.Int) declared in .Outer.Inner' type=.Outer.Inner origin=null - $outer: GET_VAR 'receiver: .Outer declared in .testInnerClassConstructorCapturingOuter.' type=.Outer origin=ADAPTED_FUNCTION_REFERENCE - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .testInnerClassConstructorCapturingOuter.' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructorCapturingOuter' type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null - $receiver: CONSTRUCTOR_CALL 'public constructor () declared in .Outer' type=.Outer origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.kt.txt deleted file mode 100644 index 5626484e8ea..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.kt.txt +++ /dev/null @@ -1,57 +0,0 @@ -fun use(fn: Function1): Any { - return fn.invoke(p1 = 42) -} - -class C { - constructor(vararg xs: Int) /* primary */ { - super/*Any*/() - /* () */ - - } - -} - -class Outer { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - inner class Inner { - constructor(vararg xs: Int) /* primary */ { - super/*Any*/() - /* () */ - - } - - } - -} - -fun testConstructor(): Any { - return use(fn = local fun (p0: Int): C { - return C(xs = [p0]) - } -) -} - -fun testInnerClassConstructor(outer: Outer): Any { - return use(fn = { // BLOCK - local fun Outer.(p0: Int): Inner { - return receiver.Inner(xs = [p0]) - } - - outer:: - }) -} - -fun testInnerClassConstructorCapturingOuter(): Any { - return use(fn = { // BLOCK - local fun Outer.(p0: Int): Inner { - return receiver.Inner(xs = [p0]) - } - - Outer():: - }) -} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.kt b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.kt index 707a72e71db..5e7fd36d4dd 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.kt +++ b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun use(fn: (Int) -> Any) = fn(42) class C(vararg xs: Int) diff --git a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.ir.txt deleted file mode 100644 index c964b9db530..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.ir.txt +++ /dev/null @@ -1,65 +0,0 @@ -FILE fqName: fileName:/kt37131.kt - FUN name:foo visibility:public modality:FINAL <> (x:kotlin.String) returnType:kotlin.String - VALUE_PARAMETER name:x index:0 type:kotlin.String - EXPRESSION_BODY - CONST String type=kotlin.String value="" - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun foo (x: kotlin.String): kotlin.String declared in ' - GET_VAR 'x: kotlin.String declared in .foo' type=kotlin.String origin=null - CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C - CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:.C [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.String - EXPRESSION_BODY - CONST String type=kotlin.String value="" - 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]' - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.String declared in .C.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.String - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.C - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .C' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C 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 - FUN name:use visibility:public modality:FINAL <> (fn:kotlin.Function0) returnType:kotlin.Any - VALUE_PARAMETER name:fn index:0 type:kotlin.Function0 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun use (fn: kotlin.Function0): kotlin.Any declared in ' - CALL 'public abstract fun invoke (): R of kotlin.Function0 declared in kotlin.Function0' type=kotlin.Any origin=INVOKE - $this: GET_VAR 'fn: kotlin.Function0 declared in .use' type=kotlin.Function0 origin=VARIABLE_AS_FUNCTION - FUN name:testFn visibility:public modality:FINAL <> () returnType:kotlin.Any - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testFn (): kotlin.Any declared in ' - CALL 'public final fun use (fn: kotlin.Function0): kotlin.Any declared in ' type=kotlin.Any origin=null - fn: FUN_EXPR type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo visibility:local modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun foo (): kotlin.String declared in .testFn' - CALL 'public final fun foo (x: kotlin.String): kotlin.String declared in ' type=kotlin.String origin=null - FUN name:testCtor visibility:public modality:FINAL <> () returnType:kotlin.Any - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testCtor (): kotlin.Any declared in ' - CALL 'public final fun use (fn: kotlin.Function0): kotlin.Any declared in ' type=kotlin.Any origin=null - fn: FUN_EXPR type=kotlin.Function0<.C> origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> () returnType:.C - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): .C declared in .testCtor' - CONSTRUCTOR_CALL 'public constructor (x: kotlin.String) declared in .C' type=.C origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.kt.txt deleted file mode 100644 index 1ee61feeda0..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.kt.txt +++ /dev/null @@ -1,34 +0,0 @@ -fun foo(x: String = ""): String { - return x -} - -class C { - constructor(x: String = "") /* primary */ { - super/*Any*/() - /* () */ - - } - - val x: String - field = x - get - -} - -fun use(fn: Function0): Any { - return fn.invoke() -} - -fun testFn(): Any { - return use(fn = local fun foo(): String { - return foo() - } -) -} - -fun testCtor(): Any { - return use(fn = local fun (): C { - return C() - } -) -} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.kt b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.kt index 0c05b1e7fa5..d88e9f02642 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.kt +++ b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun foo(x: String = ""): String = x class C(val x: String = "") diff --git a/compiler/testData/ir/irText/expressions/callableReferences/kt46069.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/kt46069.fir.ir.txt index 1b0d0872c85..3de5b49a739 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/kt46069.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/kt46069.fir.ir.txt @@ -90,5 +90,5 @@ FILE fqName: fileName:/kt46069.kt CALL 'public final fun describedAs (description: kotlin.String?, vararg args: kotlin.Any?): .ObjectAssert.ObjectAssert>? declared in .ObjectAssert' type=.ObjectAssert.ObjectAssert>? origin=null $this: GET_VAR 'receiver: .ObjectAssert.assertNotNull?> declared in .assertNotNull.describedAs' type=.ObjectAssert.assertNotNull?> origin=ADAPTED_FUNCTION_REFERENCE description: GET_VAR 'p0: kotlin.String? declared in .assertNotNull.describedAs' type=kotlin.String? origin=null - FUNCTION_REFERENCE 'local final fun describedAs (p0: kotlin.String?): .ObjectAssert.assertNotNull?>? declared in .assertNotNull' type=kotlin.Function1.ObjectAssert.assertNotNull?>?> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + FUNCTION_REFERENCE 'local final fun describedAs (p0: kotlin.String?): .ObjectAssert.assertNotNull?>? declared in .assertNotNull' type=kotlin.Function1.ObjectAssert.assertNotNull?>?> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun describedAs (description: kotlin.String?, vararg args: kotlin.Any?): .ObjectAssert.ObjectAssert>? declared in .ObjectAssert $receiver: GET_VAR 'val assert: .ObjectAssert.assertNotNull?> declared in .assertNotNull' type=.ObjectAssert.assertNotNull?> origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.fir.ir.txt index d50c495d60c..9449a11cc3a 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.fir.ir.txt @@ -66,50 +66,56 @@ FILE fqName: fileName:/suspendConversion.kt 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: FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE + 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: FUN_EXPR type=kotlin.coroutines.SuspendFunction1 origin=ADAPTED_FUNCTION_REFERENCE + 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: FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE + 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: FUN_EXPR type=kotlin.coroutines.SuspendFunction1 origin=ADAPTED_FUNCTION_REFERENCE + 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: FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE + 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: FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE + 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 @@ -119,19 +125,21 @@ FILE fqName: fileName:/suspendConversion.kt 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=null + 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: FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE + 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: FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE + 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 index d78368b9342..d2d316261a8 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.fir.kt.txt @@ -53,45 +53,63 @@ fun testNoCoversion() { } fun testSuspendPlain() { - useSuspend(fn = local suspend fun foo1() { - foo1() - } -) + useSuspend(fn = { // BLOCK + local suspend fun foo1() { + foo1() + } + + ::foo1 + }) } fun testSuspendWithArgs() { - useSuspendInt(fn = local suspend fun fooInt(p0: Int) { - fooInt(x = p0) - } -) + useSuspendInt(fn = { // BLOCK + local suspend fun fooInt(p0: Int) { + fooInt(x = p0) + } + + ::fooInt + }) } fun testWithVararg() { - useSuspend(fn = local suspend fun foo2() { - foo2() - } -) + useSuspend(fn = { // BLOCK + local suspend fun foo2() { + foo2() + } + + ::foo2 + }) } fun testWithVarargMapped() { - useSuspendInt(fn = local suspend fun foo2(p0: Int) { - foo2(xs = [p0]) - } -) + useSuspendInt(fn = { // BLOCK + local suspend fun foo2(p0: Int) { + foo2(xs = [p0]) + } + + ::foo2 + }) } fun testWithCoercionToUnit() { - useSuspend(fn = local suspend fun foo3() { - foo3() - } -) + useSuspend(fn = { // BLOCK + local suspend fun foo3() { + foo3() + } + + ::foo3 + }) } fun testWithDefaults() { - useSuspend(fn = local suspend fun foo4() { - foo4() - } -) + useSuspend(fn = { // BLOCK + local suspend fun foo4() { + foo4() + } + + ::foo4 + }) } fun testWithBoundReceiver() { @@ -105,15 +123,22 @@ fun testWithBoundReceiver() { } fun testNullableParam() { - useSuspendNullable(fn = local suspend fun foo1() { - foo1() - } -) + useSuspendNullable(fn = { // BLOCK + local suspend fun foo1() { + foo1() + } + + ::foo1 + }) } fun testNestedNullableParam() { - useSuspendNestedNullable(fn = local suspend fun foo1() { - foo1() - } -) + useSuspendNestedNullable(fn = { // BLOCK + local suspend fun foo1() { + foo1() + } + + ::foo1 + }) } + diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.ir.txt index 8e12eb775b0..379838b11e1 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.ir.txt @@ -60,7 +60,7 @@ FILE fqName: fileName:/unboundMemberReferenceWithAdaptedArguments.kt 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: FUN_EXPR type=kotlin.Function2<.A, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE + 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 @@ -69,6 +69,7 @@ FILE fqName: fileName:/unboundMemberReferenceWithAdaptedArguments.kt $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 @@ -82,7 +83,7 @@ FILE fqName: fileName:/unboundMemberReferenceWithAdaptedArguments.kt $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=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 @@ -96,5 +97,5 @@ FILE fqName: fileName:/unboundMemberReferenceWithAdaptedArguments.kt $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=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 index 5a8cd7bbd58..0bc7d6bf318 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.kt.txt @@ -31,10 +31,13 @@ object Obj : A { } fun testUnbound() { - use1(fn = local fun foo(p0: A, p1: Int) { - p0.foo(xs = [p1]) - } -) + use1(fn = { // BLOCK + local fun foo(p0: A, p1: Int) { + p0.foo(xs = [p1]) + } + + ::foo + }) } fun testBound(a: A) { @@ -56,3 +59,4 @@ fun testObject() { Obj::foo }) } + diff --git a/compiler/testData/ir/irText/expressions/callableReferences/varargFunImportedFromObject.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/varargFunImportedFromObject.fir.ir.txt deleted file mode 100644 index 70605521ba9..00000000000 --- a/compiler/testData/ir/irText/expressions/callableReferences/varargFunImportedFromObject.fir.ir.txt +++ /dev/null @@ -1,65 +0,0 @@ -FILE fqName: fileName:/varargFunImportedFromObject.kt - FUN name:withO 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 withO (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 .withO' type=kotlin.Function1 origin=VARIABLE_AS_FUNCTION - p1: CONST String type=kotlin.String value="O" - 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:foo visibility:public modality:FINAL <> ($this:.Host, x:kotlin.Array) returnType:kotlin.String - $this: VALUE_PARAMETER name: type:.Host - VALUE_PARAMETER name:x index:0 type:kotlin.Array varargElementType:kotlin.String [vararg] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun foo (vararg x: kotlin.String): kotlin.String declared in .Host' - CONST String type=kotlin.String value="K" - 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:test1 visibility:public modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.String declared in ' - CALL 'public final fun withO (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:foo visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.String) 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.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun foo (p0: kotlin.String): kotlin.String declared in .test1' - CALL 'public final fun foo (vararg x: kotlin.String): kotlin.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR 'receiver: .Host declared in .test1.foo' type=.Host origin=ADAPTED_FUNCTION_REFERENCE - x: VARARG type=kotlin.Array varargElementType=kotlin.String - GET_VAR 'p0: kotlin.String declared in .test1.foo' type=kotlin.String origin=null - FUNCTION_REFERENCE 'local final fun foo (p0: kotlin.String): kotlin.String declared in .test1' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null - $receiver: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host - FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.String declared in ' - CALL 'public final fun withO (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:foo visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.String) 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.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun foo (p0: kotlin.String): kotlin.String declared in .test2' - CALL 'public final fun foo (vararg x: kotlin.String): kotlin.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR 'receiver: .Host declared in .test2.foo' type=.Host origin=ADAPTED_FUNCTION_REFERENCE - x: VARARG type=kotlin.Array varargElementType=kotlin.String - GET_VAR 'p0: kotlin.String declared in .test2.foo' type=kotlin.String origin=null - FUNCTION_REFERENCE 'local final fun foo (p0: kotlin.String): kotlin.String declared in .test2' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null - $receiver: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host diff --git a/compiler/testData/ir/irText/expressions/callableReferences/varargFunImportedFromObject.kt b/compiler/testData/ir/irText/expressions/callableReferences/varargFunImportedFromObject.kt index 729a3ad27bc..fb93a3a6885 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/varargFunImportedFromObject.kt +++ b/compiler/testData/ir/irText/expressions/callableReferences/varargFunImportedFromObject.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // SKIP_KT_DUMP import Host.foo diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.fir.ir.txt index 2b473923c85..58d6bc29986 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.fir.ir.txt @@ -29,10 +29,11 @@ FILE fqName: fileName:/withAdaptationForSam.kt BLOCK_BODY CALL 'public final fun useFoo (foo: .IFoo): kotlin.Unit declared in ' type=kotlin.Unit origin=null foo: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo - FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + BLOCK type=kotlin.Function1 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 + 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 index 66a0dce09b3..7205e1690cf 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.fir.kt.txt @@ -11,8 +11,12 @@ fun withVararg(vararg xs: Int): Int { } fun test() { - useFoo(foo = local fun withVararg(p0: Int) { - withVararg(xs = [p0]) - } - /*-> IFoo */) + useFoo(foo = { // BLOCK + local fun withVararg(p0: Int) { + withVararg(xs = [p0]) + } + + ::withVararg + } /*-> IFoo */) } + diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.ir.txt index abd6eb311e3..a7ff9f14acc 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.ir.txt @@ -67,18 +67,19 @@ FILE fqName: fileName:/withAdaptedArguments.kt 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: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + 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: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + 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 @@ -86,16 +87,18 @@ FILE fqName: fileName:/withAdaptedArguments.kt 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: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + 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 ' @@ -110,23 +113,25 @@ FILE fqName: fileName:/withAdaptedArguments.kt $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=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: FUN_EXPR type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE + 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: FUN_EXPR type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE + 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 index 3940b664756..efd24aecbf8 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.kt.txt @@ -35,24 +35,33 @@ object Host { } fun testDefault(): String { - return use(fn = local fun fnWithDefault(p0: Int): String { - return fnWithDefault(a = p0) - } -) + return use(fn = { // BLOCK + local fun fnWithDefault(p0: Int): String { + return fnWithDefault(a = p0) + } + + ::fnWithDefault + }) } fun testVararg(): String { - return use(fn = local fun fnWithVarargs(p0: Int): String { - return fnWithVarargs(xs = [p0]) - } -) + return use(fn = { // BLOCK + local fun fnWithVarargs(p0: Int): String { + return fnWithVarargs(xs = [p0]) + } + + ::fnWithVarargs + }) } fun testCoercionToUnit() { - return coerceToUnit(fn = local fun fnWithDefault(p0: Int) { - fnWithDefault(a = p0) - } -) + return coerceToUnit(fn = { // BLOCK + local fun fnWithDefault(p0: Int) { + fnWithDefault(a = p0) + } + + ::fnWithDefault + }) } fun testImportedObjectMember(): String { @@ -66,15 +75,22 @@ fun testImportedObjectMember(): String { } fun testDefault0(): String { - return use0(fn = local fun fnWithDefaults(): String { - return fnWithDefaults() - } -) + return use0(fn = { // BLOCK + local fun fnWithDefaults(): String { + return fnWithDefaults() + } + + ::fnWithDefaults + }) } fun testVararg0(): String { - return use0(fn = local fun fnWithVarargs(): String { - return fnWithVarargs() - } -) + return use0(fn = { // BLOCK + local fun fnWithVarargs(): String { + return fnWithVarargs() + } + + ::fnWithVarargs + }) } + diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.ir.txt index 15fdac6ba97..139efeabaf2 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.ir.txt @@ -30,7 +30,7 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt $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=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 @@ -47,7 +47,7 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt $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=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 @@ -64,7 +64,7 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt $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=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 @@ -80,7 +80,7 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt $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=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 @@ -95,7 +95,7 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt $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=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: diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.ir.txt index 7402497dd98..b7635f67379 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.ir.txt @@ -62,7 +62,7 @@ FILE fqName: fileName:/withVarargViewedAsArray.kt FUN name:testPlainArgs visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun usePlainArgs (fn: kotlin.Function2): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.Function2 origin=ADAPTED_FUNCTION_REFERENCE + fn: BLOCK type=kotlin.Function2 origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:sum visibility:local modality:FINAL <> (p0:kotlin.Int, p1:kotlin.Int) returnType:kotlin.Int VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p1 index:1 type:kotlin.Int @@ -72,6 +72,7 @@ FILE fqName: fileName:/withVarargViewedAsArray.kt args: VARARG type=kotlin.IntArray varargElementType=kotlin.Int GET_VAR 'p0: kotlin.Int declared in .testPlainArgs.sum' type=kotlin.Int origin=null GET_VAR 'p1: kotlin.Int declared in .testPlainArgs.sum' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun sum (p0: kotlin.Int, p1: kotlin.Int): kotlin.Int declared in .testPlainArgs' type=kotlin.Function2 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun sum (vararg args: kotlin.Int): kotlin.Int declared in FUN name:testPrimitiveArrayAsVararg visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun usePrimitiveArray (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null @@ -83,7 +84,7 @@ FILE fqName: fileName:/withVarargViewedAsArray.kt FUN name:testArrayAndDefaults visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun useStringArray (fn: kotlin.Function1, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.Function1, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE + fn: BLOCK type=kotlin.Function1, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:zap visibility:local modality:FINAL <> (p0:kotlin.Array) returnType:kotlin.Unit VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Array BLOCK_BODY @@ -91,3 +92,4 @@ FILE fqName: fileName:/withVarargViewedAsArray.kt b: VARARG type=kotlin.Array varargElementType=kotlin.String SPREAD_ELEMENT GET_VAR 'p0: kotlin.Array declared in .testArrayAndDefaults.zap' type=kotlin.Array origin=null + FUNCTION_REFERENCE 'local final fun zap (p0: kotlin.Array): kotlin.Unit declared in .testArrayAndDefaults' type=kotlin.Function1, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun zap (vararg b: kotlin.String, k: kotlin.Int): kotlin.Unit declared in diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.kt.txt index 70e2e380f0a..5f0670a3820 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.kt.txt @@ -35,10 +35,13 @@ fun useStringArray(fn: Function1, Unit>) { } fun testPlainArgs() { - usePlainArgs(fn = local fun sum(p0: Int, p1: Int): Int { - return sum(args = [p0, p1]) - } -) + usePlainArgs(fn = { // BLOCK + local fun sum(p0: Int, p1: Int): Int { + return sum(args = [p0, p1]) + } + + ::sum + }) } fun testPrimitiveArrayAsVararg() { @@ -50,8 +53,12 @@ fun testArrayAsVararg() { } fun testArrayAndDefaults() { - useStringArray(fn = local fun zap(p0: Array) { - zap(b = [*p0]) - } -) + useStringArray(fn = { // BLOCK + local fun zap(p0: Array) { + zap(b = [*p0]) + } + + ::zap + }) } + 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 79bdac14294..66dc4547842 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.fir.ir.txt @@ -66,10 +66,11 @@ FILE fqName: fileName:/samConversionInVarargs.kt CALL 'public final fun useVararg (vararg foos: .IFoo): kotlin.Unit declared in ' type=kotlin.Unit origin=null foos: VARARG type=kotlin.Array.IFoo> varargElementType=.IFoo TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo - FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + BLOCK type=kotlin.Function1 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 ' 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 + 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 d37014897d3..100ac6975a5 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.fir.kt.txt @@ -31,8 +31,12 @@ fun withVarargOfInt(vararg xs: Int): String { } fun testAdaptedCR() { - useVararg(foos = [local fun withVarargOfInt(p0: Int) { - withVarargOfInt(xs = [p0]) - } - /*-> IFoo */]) + useVararg(foos = [{ // BLOCK + local fun withVarargOfInt(p0: Int) { + withVarargOfInt(xs = [p0]) + } + + ::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 index 2b20f9c1531..160ffc42011 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.ir.txt @@ -35,10 +35,11 @@ FILE fqName: fileName:/samConversionOnCallableReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testSamCosntructorOnAdapted (): .KRunnable declared in ' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - FUN_EXPR type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE + 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 @@ -48,7 +49,8 @@ FILE fqName: fileName:/samConversionOnCallableReference.kt 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 - FUN_EXPR type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE + 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 .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 index 38484efcba1..34748adea95 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.kt.txt @@ -18,10 +18,13 @@ fun testSamConstructor(): KRunnable { } fun testSamCosntructorOnAdapted(): KRunnable { - return local fun foo1() { - foo1() - } - /*-> KRunnable */ + return { // BLOCK + local fun foo1() { + foo1() + } + + ::foo1 + } /*-> KRunnable */ } fun testSamConversion() { @@ -29,8 +32,12 @@ fun testSamConversion() { } fun testSamConversionOnAdapted() { - use(r = local fun foo1() { - foo1() - } - /*-> KRunnable */) + use(r = { // BLOCK + local fun foo1() { + foo1() + } + + ::foo1 + } /*-> KRunnable */) } + diff --git a/compiler/testData/ir/irText/expressions/suspendConversionWithFunInterfaces.fir.ir.txt b/compiler/testData/ir/irText/expressions/suspendConversionWithFunInterfaces.fir.ir.txt index dd4d57fd4a2..19abe67cdba 100644 --- a/compiler/testData/ir/irText/expressions/suspendConversionWithFunInterfaces.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/suspendConversionWithFunInterfaces.fir.ir.txt @@ -41,19 +41,22 @@ FILE fqName: fileName:/suspendConversionWithFunInterfaces.kt BLOCK_BODY CALL 'public final fun foo1 (s: .SuspendRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null s: TYPE_OP type=.SuspendRunnable origin=SAM_CONVERSION typeOperand=.SuspendRunnable - FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE + BLOCK type=kotlin.coroutines.SuspendFunction0 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 ' type=kotlin.Unit origin=null + FUNCTION_REFERENCE 'local final fun bar1 (): kotlin.Unit declared in .box' type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun bar1 (): kotlin.Unit declared in CALL 'public final fun foo1 (s: .SuspendRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null s: TYPE_OP type=.SuspendRunnable origin=SAM_CONVERSION typeOperand=.SuspendRunnable - FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE + BLOCK type=kotlin.coroutines.SuspendFunction0 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 + 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 s: TYPE_OP type=.SuspendRunnable origin=SAM_CONVERSION typeOperand=.SuspendRunnable - FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE + BLOCK type=kotlin.coroutines.SuspendFunction0 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 ' type=kotlin.Unit origin=null + FUNCTION_REFERENCE 'local final fun bar3 (): kotlin.Unit declared in .box' type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun bar3 (): kotlin.Unit declared in diff --git a/compiler/testData/ir/irText/firProblems/cannotCastToFunction.fir.ir.txt b/compiler/testData/ir/irText/firProblems/cannotCastToFunction.fir.ir.txt index 07380e6e740..1737758047e 100644 --- a/compiler/testData/ir/irText/firProblems/cannotCastToFunction.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/cannotCastToFunction.fir.ir.txt @@ -47,22 +47,24 @@ FILE fqName: fileName:/cannotCastToFunction.kt if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'dumpStrategy: kotlin.String declared in .dump' type=kotlin.String origin=null arg1: CONST String type=kotlin.String value="KotlinLike" - then: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.IrElement, kotlin.String> origin=ADAPTED_FUNCTION_REFERENCE + then: BLOCK type=@[ExtensionFunctionType] kotlin.Function1<.IrElement, kotlin.String> origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:dumpKotlinLike visibility:local modality:FINAL <> (p0:.IrElement) returnType:kotlin.String VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:.IrElement BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun dumpKotlinLike (p0: .IrElement): kotlin.String declared in .dump' CALL 'public final fun dumpKotlinLike (options: kotlin.String): kotlin.String declared in ' type=kotlin.String origin=null $receiver: GET_VAR 'p0: .IrElement declared in .dump.dumpKotlinLike' type=.IrElement origin=null + FUNCTION_REFERENCE 'local final fun dumpKotlinLike (p0: .IrElement): kotlin.String declared in .dump' type=@[ExtensionFunctionType] kotlin.Function1<.IrElement, kotlin.String> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun dumpKotlinLike (options: kotlin.String): kotlin.String declared in BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.IrElement, kotlin.String> origin=ADAPTED_FUNCTION_REFERENCE + then: BLOCK type=@[ExtensionFunctionType] kotlin.Function1<.IrElement, kotlin.String> origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:dump visibility:local modality:FINAL <> (p0:.IrElement) returnType:kotlin.String VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:.IrElement BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun dump (p0: .IrElement): kotlin.String declared in .dump' CALL 'public final fun dump (normalizeNames: kotlin.Boolean, stableOrder: kotlin.Boolean): kotlin.String declared in ' type=kotlin.String origin=null $receiver: GET_VAR 'p0: .IrElement declared in .dump.dump' type=.IrElement origin=null + FUNCTION_REFERENCE 'local final fun dump (p0: .IrElement): kotlin.String declared in .dump' type=@[ExtensionFunctionType] kotlin.Function1<.IrElement, kotlin.String> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun dump (normalizeNames: kotlin.Boolean, stableOrder: kotlin.Boolean): kotlin.String declared in RETURN type=kotlin.Nothing from='public final fun dump (data: .IrElement, dumpStrategy: kotlin.String): 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 'val dump: @[ExtensionFunctionType] kotlin.Function1<.IrElement, kotlin.String> declared in .dump' type=@[ExtensionFunctionType] kotlin.Function1<.IrElement, kotlin.String> origin=VARIABLE_AS_FUNCTION diff --git a/compiler/testData/ir/irText/firProblems/cannotCastToFunction.fir.kt.txt b/compiler/testData/ir/irText/firProblems/cannotCastToFunction.fir.kt.txt index 9ebfd9b29ee..fcf50400cf6 100644 --- a/compiler/testData/ir/irText/firProblems/cannotCastToFunction.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/cannotCastToFunction.fir.kt.txt @@ -17,14 +17,21 @@ fun IrElement.dump(normalizeNames: Boolean = false, stableOrder: Boolean = false fun dump(data: IrElement, dumpStrategy: String): String { val dump: @ExtensionFunctionType Function1 = when { - EQEQ(arg0 = dumpStrategy, arg1 = "KotlinLike") -> local fun dumpKotlinLike(p0: IrElement): String { - return p0.dumpKotlinLike() - } + EQEQ(arg0 = dumpStrategy, arg1 = "KotlinLike") -> { // BLOCK + local fun dumpKotlinLike(p0: IrElement): String { + return p0.dumpKotlinLike() + } - else -> local fun dump(p0: IrElement): String { - return p0.dump() + ::dumpKotlinLike } + else -> { // BLOCK + local fun dump(p0: IrElement): String { + return p0.dump() + } + ::dump + } } return dump.invoke(p1 = data) } +