From bb8bf28b8b89c264cf1f801b8052d3c29d484b60 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Mon, 1 Feb 2021 15:35:03 +0500 Subject: [PATCH] [PSI2IR] Set reflectionTarget for all adapted references --- .../ReflectionReferencesGenerator.kt | 21 ++---- .../adaptedExtensionFunctions.kt.txt | 33 ++++++---- .../adaptedExtensionFunctions.txt | 9 ++- .../adaptedWithCoercionToUnit.kt.txt | 44 ++++++++----- .../adaptedWithCoercionToUnit.txt | 12 ++-- .../boundInlineAdaptedReference.txt | 2 +- .../caoWithAdaptationForSam.kt.txt | 22 ++++--- .../caoWithAdaptationForSam.txt | 6 +- .../constructorWithAdaptedArguments.kt.txt | 11 ++-- .../constructorWithAdaptedArguments.txt | 7 +- .../callableReferences/kt37131.kt.txt | 22 ++++--- .../callableReferences/kt37131.txt | 6 +- .../suspendConversion.kt.txt | 66 ++++++++++++------- .../callableReferences/suspendConversion.txt | 20 ++++-- ...MemberReferenceWithAdaptedArguments.kt.txt | 11 ++-- ...undMemberReferenceWithAdaptedArguments.txt | 7 +- .../withAdaptationForSam.kt.txt | 11 ++-- .../withAdaptationForSam.txt | 3 +- .../withAdaptedArguments.kt.txt | 55 ++++++++++------ .../withAdaptedArguments.txt | 17 +++-- .../withArgumentAdaptationAndReceiver.txt | 10 +-- .../withVarargViewedAsArray.kt.txt | 22 ++++--- .../withVarargViewedAsArray.txt | 6 +- .../samConversionInVarargs.kt.txt | 11 ++-- .../funInterface/samConversionInVarargs.txt | 3 +- .../samConversionOnCallableReference.kt.txt | 22 ++++--- .../samConversionOnCallableReference.txt | 6 +- 27 files changed, 289 insertions(+), 176 deletions(-) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt index 7abed0ee355..21a067338ca 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt @@ -159,20 +159,13 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St "Bound callable reference cannot have both receivers: $adapteeDescriptor" } val receiver = irDispatchReceiver ?: irExtensionReceiver - if (receiver == null) { - IrFunctionExpressionImpl( - startOffset, endOffset, irFunctionalType, irAdapterFun, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE - ) - } else { - // TODO add a bound receiver property to IrFunctionExpressionImpl? - val irAdapterRef = IrFunctionReferenceImpl( - startOffset, endOffset, irFunctionalType, irAdapterFun.symbol, irAdapterFun.typeParameters.size, - irAdapterFun.valueParameters.size, null, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE - ) - IrBlockImpl(startOffset, endOffset, irFunctionalType, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE).apply { - statements.add(irAdapterFun) - statements.add(irAdapterRef.apply { extensionReceiver = receiver }) - } + val irAdapterRef = IrFunctionReferenceImpl( + startOffset, endOffset, irFunctionalType, irAdapterFun.symbol, irAdapterFun.typeParameters.size, + irAdapterFun.valueParameters.size, adapteeSymbol, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE + ) + IrBlockImpl(startOffset, endOffset, irFunctionalType, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE).apply { + statements.add(irAdapterFun) + statements.add(irAdapterRef.apply { extensionReceiver = receiver }) } } } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.kt.txt index 59c4b5eb534..b28c2fbf482 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.kt.txt @@ -20,23 +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/adaptedExtensionFunctions.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.txt index 318a0636e69..524ec3aa4ce 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.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=kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE + f: BLOCK type=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=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=kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE + f: BLOCK type=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=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=kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE + f: BLOCK type=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=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/adaptedWithCoercionToUnit.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.kt.txt index 856a06456a7..c50ccf7abca 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.kt.txt @@ -17,30 +17,42 @@ fun fnv(vararg xs: Int): Int { } fun test0() { - return useUnit0(fn = local fun fn0() { - fn0() /*~> Unit */ - } -) + return useUnit0(fn = { // BLOCK + local fun fn0() { + fn0() /*~> Unit */ + } + + ::fn0 + }) } fun test1() { - return useUnit1(fn = local fun fn1(p0: Int) { - fn1(x = p0) /*~> Unit */ - } -) + return useUnit1(fn = { // BLOCK + local fun fn1(p0: Int) { + fn1(x = p0) /*~> Unit */ + } + + ::fn1 + }) } fun testV0() { - return useUnit0(fn = local fun fnv() { - fnv() /*~> Unit */ - } -) + return useUnit0(fn = { // BLOCK + local fun fnv() { + fnv() /*~> Unit */ + } + + ::fnv + }) } fun testV1() { - return useUnit1(fn = local fun fnv(p0: Int) { - fnv(xs = [p0]) /*~> Unit */ - } -) + return useUnit1(fn = { // BLOCK + local fun fnv(p0: Int) { + fnv(xs = [p0]) /*~> Unit */ + } + + ::fnv + }) } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.txt index e70b3788e54..f7701b314e0 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.txt @@ -23,36 +23,39 @@ 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 TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit 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 TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit 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 TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit 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 @@ -60,3 +63,4 @@ FILE fqName: fileName:/adaptedWithCoercionToUnit.kt 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/boundInlineAdaptedReference.txt b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.txt index e11e0cc7e4e..a7545077304 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.txt @@ -21,5 +21,5 @@ FILE fqName:test fileName:/boundInlineAdaptedReference.kt TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit 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.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.kt.txt index 225648dd90a..180f88e39f0 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.kt.txt @@ -46,10 +46,13 @@ fun withVararg(vararg xs: Int): Int { fun test1() { { // BLOCK val tmp0_array: A = A - val tmp2_sam: IFoo = local fun withVararg(p0: Int) { - withVararg(xs = [p0]) /*~> Unit */ - } - /*-> IFoo */ + val tmp2_sam: IFoo = { // BLOCK + local fun withVararg(p0: Int) { + withVararg(xs = [p0]) /*~> Unit */ + } + + ::withVararg + } /*-> IFoo */ tmp0_array.set(i = tmp2_sam, newValue = tmp0_array.get(i = tmp2_sam).plus(other = 1)) } } @@ -57,10 +60,13 @@ fun test1() { fun test2() { { // BLOCK val tmp0_array: B = B - val tmp2_sam: IFoo2 = local fun withVararg(p0: Int) { - withVararg(xs = [p0]) /*~> Unit */ - } - /*-> IFoo2 */ + val tmp2_sam: IFoo2 = { // BLOCK + local fun withVararg(p0: Int) { + withVararg(xs = [p0]) /*~> Unit */ + } + + ::withVararg + } /*-> IFoo2 */ tmp0_array.set(i = tmp2_sam, newValue = tmp0_array.get(i = tmp2_sam).plus(other = 1)) } } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.txt index 46b03f58936..640f58b385d 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.txt @@ -109,7 +109,7 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.IFoo [val] 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 @@ -117,6 +117,7 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt 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 [operator] declared in ' type=kotlin.Unit origin=PLUSEQ $receiver: GET_VAR 'val tmp_0: .A [val] declared in .test1' type=.A origin=null i: GET_VAR 'val tmp_1: .IFoo [val] declared in .test1' type=.IFoo origin=null @@ -132,7 +133,7 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt GET_OBJECT 'CLASS OBJECT name:B modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.B VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:.IFoo2 [val] TYPE_OP type=.IFoo2 origin=SAM_CONVERSION typeOperand=.IFoo2 - 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 @@ -140,6 +141,7 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt 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 [operator] declared in ' type=kotlin.Unit origin=PLUSEQ $receiver: GET_VAR 'val tmp_2: .B [val] declared in .test2' type=.B origin=null i: GET_VAR 'val tmp_3: .IFoo2 [val] declared in .test2' type=.IFoo2 origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.kt.txt index f0d6fc7435b..d6de3bb4cc7 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.kt.txt @@ -30,10 +30,13 @@ class Outer { } fun testConstructor(): Any { - return use(fn = local fun (p0: Int): C { - return C(xs = [p0]) - } -) + return use(fn = { // BLOCK + local fun (p0: Int): C { + return C(xs = [p0]) + } + + :: + }) } fun testInnerClassConstructor(outer: Outer): Any { diff --git a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt index 82ebbb6d5a9..f6b50e40710 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt @@ -70,7 +70,7 @@ FILE fqName: fileName:/constructorWithAdaptedArguments.kt 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 + fn: BLOCK 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 @@ -78,6 +78,7 @@ FILE fqName: fileName:/constructorWithAdaptedArguments.kt CONSTRUCTOR_CALL 'public constructor (vararg xs: kotlin.Int) [primary] 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 + FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .C declared in .testConstructor' type=kotlin.Function1.C> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public constructor (vararg xs: kotlin.Int) [primary] declared in .C FUN name:testInnerClassConstructor visibility:public modality:FINAL <> (outer:.Outer) returnType:kotlin.Any VALUE_PARAMETER name:outer index:0 type:.Outer BLOCK_BODY @@ -93,7 +94,7 @@ FILE fqName: fileName:/constructorWithAdaptedArguments.kt $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 + FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructor' type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public constructor (vararg xs: kotlin.Int) [primary] declared in .Outer.Inner $receiver: GET_VAR 'outer: .Outer declared in .testInnerClassConstructor' type=.Outer origin=null FUN name:testInnerClassConstructorCapturingOuter visibility:public modality:FINAL <> () returnType:kotlin.Any BLOCK_BODY @@ -109,5 +110,5 @@ FILE fqName: fileName:/constructorWithAdaptedArguments.kt $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 + FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructorCapturingOuter' type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public constructor (vararg xs: kotlin.Int) [primary] declared in .Outer.Inner $receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Outer' type=.Outer origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.kt.txt index ae24664ea68..d82251e4fd9 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.kt.txt @@ -20,16 +20,22 @@ fun use(fn: Function0): Any { } fun testFn(): Any { - return use(fn = local fun foo(): String { - return foo() - } -) + return use(fn = { // BLOCK + local fun foo(): String { + return foo() + } + + ::foo + }) } fun testCtor(): Any { - return use(fn = local fun (): C { - return C() - } -) + return use(fn = { // BLOCK + local fun (): C { + return C() + } + + :: + }) } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.txt b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.txt index af4140b63a2..528fb8b40a9 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.txt @@ -49,17 +49,19 @@ FILE fqName: fileName:/kt37131.kt 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 + fn: BLOCK 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 + FUNCTION_REFERENCE 'local final fun foo (): kotlin.String declared in .testFn' type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo (x: kotlin.String): kotlin.String declared in 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 + fn: BLOCK 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) [primary] declared in .C' type=.C origin=null + FUNCTION_REFERENCE 'local final fun (): .C declared in .testCtor' type=kotlin.Function0<.C> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public constructor (x: kotlin.String) [primary] declared in .C diff --git a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.kt.txt index 819654386de..4d38f21ca77 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.kt.txt @@ -47,45 +47,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() /*~> Unit */ - } -) + useSuspend(fn = { // BLOCK + local suspend fun foo3() { + foo3() /*~> Unit */ + } + + ::foo3 + }) } fun testWithDefaults() { - useSuspend(fn = local suspend fun foo4() { - foo4() - } -) + useSuspend(fn = { // BLOCK + local suspend fun foo4() { + foo4() + } + + ::foo4 + }) } fun testWithBoundReceiver() { diff --git a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.txt b/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.txt index f851b2796da..7683500d480 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.txt @@ -60,51 +60,57 @@ 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 [suspend] 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 [suspend] 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 [suspend] 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 [suspend] 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 TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun foo3 (): kotlin.Int declared in ' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun foo3 (): kotlin.Unit [suspend] 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 [suspend] 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 @@ -114,5 +120,5 @@ 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 [suspend] declared in .testWithBoundReceiver' type=kotlin.coroutines.SuspendFunction0 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + FUNCTION_REFERENCE 'local final fun bar (): kotlin.Unit [suspend] 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 () [primary] declared in .C' type=.C origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt.txt index 0c62925f2bd..f5f6b2fd767 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt.txt @@ -31,10 +31,13 @@ object Obj : A { } fun testUnbound() { - use1(fn = local fun foo(p0: A, p1: Int) { - p0.foo(xs = [p1]) /*~> Unit */ - } -) + use1(fn = { // BLOCK + local fun foo(p0: A, p1: Int) { + p0.foo(xs = [p1]) /*~> Unit */ + } + + ::foo + }) } fun testBound(a: A) { diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt index 981458ab0ef..533f39bbbdf 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.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 @@ -70,6 +70,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 @@ -84,7 +85,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 @@ -99,5 +100,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/withAdaptationForSam.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.kt.txt index 968be6d330d..eb62bd54da5 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.kt.txt @@ -11,9 +11,12 @@ fun withVararg(vararg xs: Int): Int { } fun test() { - useFoo(foo = local fun withVararg(p0: Int) { - withVararg(xs = [p0]) /*~> Unit */ - } - /*-> IFoo */) + useFoo(foo = { // BLOCK + local fun withVararg(p0: Int) { + withVararg(xs = [p0]) /*~> Unit */ + } + + ::withVararg + } /*-> IFoo */) } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.txt index 890de177a47..8a109b9a2dd 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.txt @@ -29,7 +29,7 @@ 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 @@ -37,3 +37,4 @@ FILE fqName: fileName:/withAdaptationForSam.kt 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/withAdaptedArguments.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.kt.txt index da3f88aa6d4..79c979ac54c 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.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) /*~> Unit */ - } -) + return coerceToUnit(fn = { // BLOCK + local fun fnWithDefault(p0: Int) { + fnWithDefault(a = p0) /*~> Unit */ + } + + ::fnWithDefault + }) } fun testImportedObjectMember(): String { @@ -66,16 +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/withAdaptedArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt index ee0ca71d123..fcfdf40e20c 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.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,17 +87,19 @@ 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 TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit 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 ' @@ -109,23 +112,25 @@ FILE fqName: fileName:/withAdaptedArguments.kt CALL 'public final fun importedObjectMemberWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in .Host' type=kotlin.String origin=null 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/withArgumentAdaptationAndReceiver.txt b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt index 9c7a9388e33..f5053154d12 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt @@ -31,7 +31,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 @@ -49,7 +49,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 [val] 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 @@ -67,7 +67,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 [var] 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 @@ -84,7 +84,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 @@ -100,7 +100,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 () [primary] 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.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.kt.txt index 90a6f0853cd..70f290515ea 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.kt.txt @@ -33,10 +33,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() { @@ -48,9 +51,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/callableReferences/withVarargViewedAsArray.txt b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.txt index 10137266efc..684f8df7dc6 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.txt @@ -61,7 +61,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 @@ -71,6 +71,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 @@ -82,7 +83,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 @@ -90,3 +91,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/funInterface/samConversionInVarargs.kt.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.kt.txt index 2374a0e3e50..b1b65db1e08 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.kt.txt @@ -31,9 +31,12 @@ fun withVarargOfInt(vararg xs: Int): String { } fun testAdaptedCR() { - useVararg(foos = [local fun withVarargOfInt(p0: Int) { - withVarargOfInt(xs = [p0]) /*~> Unit */ - } - /*-> IFoo */]) + useVararg(foos = [{ // BLOCK + local fun withVarargOfInt(p0: Int) { + withVarargOfInt(xs = [p0]) /*~> Unit */ + } + + ::withVarargOfInt + } /*-> IFoo */]) } diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.txt index df7093b1723..1c3922a785f 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.txt @@ -66,7 +66,7 @@ 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 @@ -74,3 +74,4 @@ FILE fqName: fileName:/samConversionInVarargs.kt 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/samConversionOnCallableReference.kt.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt.txt index 4efa141094d..08502590341 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt.txt @@ -18,10 +18,13 @@ fun testSamConstructor(): KRunnable { } fun testSamCosntructorOnAdapted(): KRunnable { - return local fun foo1() { - foo1() /*~> Unit */ - } - /*-> KRunnable */ + return { // BLOCK + local fun foo1() { + foo1() /*~> Unit */ + } + + ::foo1 + } /*-> KRunnable */ } fun testSamConversion() { @@ -29,9 +32,12 @@ fun testSamConversion() { } fun testSamConversionOnAdapted() { - use(r = local fun foo1() { - foo1() /*~> Unit */ - } - /*-> KRunnable */) + use(r = { // BLOCK + local fun foo1() { + foo1() /*~> Unit */ + } + + ::foo1 + } /*-> KRunnable */) } diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.txt index d4c0fa43c6f..4e955691a7e 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.txt @@ -35,11 +35,12 @@ 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 TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit 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 @@ -49,8 +50,9 @@ 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 TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit 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