From 2c4fcebfec39e329b970a8b5a072cf4865c0015a Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Thu, 16 Apr 2020 13:49:34 +0300 Subject: [PATCH] IR: handle adapted bound references --- .../ir/FirBlackBoxCodegenTestGenerated.java | 5 ++++ .../ReflectionReferencesGenerator.kt | 27 +++++++++++++++++-- .../ir/expressions/IrStatementOrigin.kt | 1 + .../box/callableReference/bound/adapted.kt | 5 ++++ .../adaptedExtensionFunctions.txt | 6 ++--- .../adaptedWithCoercionToUnit.txt | 8 +++--- .../caoWithAdaptationForSam.txt | 4 +-- .../constructorWithAdaptedArguments.txt | 8 +++--- .../callableReferences/kt37131.txt | 4 +-- ...undMemberReferenceWithAdaptedArguments.txt | 6 ++--- .../withAdaptationForSam.txt | 2 +- .../withAdaptedArguments.txt | 12 ++++----- .../withArgumentAdaptationAndReceiver.txt | 14 +++++----- .../withVarargViewedAsArray.txt | 4 +-- .../funInterface/samConversionInVarargs.txt | 2 +- .../samConversionOnCallableReference.txt | 4 +-- .../codegen/BlackBoxCodegenTestGenerated.java | 5 ++++ .../LightAnalysisModeTestGenerated.java | 5 ++++ .../ir/IrBlackBoxCodegenTestGenerated.java | 5 ++++ .../kotlin/builtins/functionTypes.kt | 3 +++ .../IrJsCodegenBoxTestGenerated.java | 5 ++++ .../semantics/JsCodegenBoxTestGenerated.java | 5 ++++ 22 files changed, 101 insertions(+), 39 deletions(-) create mode 100644 compiler/testData/codegen/box/callableReference/bound/adapted.kt diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 5a7e8cfc973..2a47c910a76 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -2119,6 +2119,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: "); } + @TestMetadata("adapted.kt") + public void testAdapted() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/adapted.kt"); + } + public void testAllFilesPresentInBound() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/bound"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } 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 1ac9f8fe58a..abe4c9fc901 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 @@ -17,6 +17,9 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.builtins.createFunctionType +import org.jetbrains.kotlin.builtins.isKFunctionType +import org.jetbrains.kotlin.builtins.isKSuspendFunctionType import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl @@ -28,6 +31,9 @@ import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol +import org.jetbrains.kotlin.ir.types.IrSimpleType +import org.jetbrains.kotlin.ir.types.defaultType +import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.util.referenceClassifier import org.jetbrains.kotlin.ir.util.referenceFunction import org.jetbrains.kotlin.ir.util.withScope @@ -116,7 +122,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St val adapteeSymbol = context.symbolTable.referenceFunction(adapteeDescriptor.original) val ktFunctionalType = getTypeInferredByFrontendOrFail(ktCallableReference) - val irFunctionalType = ktFunctionalType.toIrType() + val irFunctionalType = ktFunctionalType.maybeKFunctionTypeToFunctionType().toIrType() val ktFunctionalTypeArguments = ktFunctionalType.arguments val ktExpectedReturnType = ktFunctionalTypeArguments.last().type @@ -137,7 +143,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St startOffset, endOffset, irFunctionalType, irAdapterFun, - IrStatementOrigin.LAMBDA + IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE ) return if (adapteeCall.tmpReceivers.isEmpty()) { @@ -487,4 +493,21 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St context.callToSubstitutedDescriptorMap[this] = descriptor putTypeArguments(typeArguments) { it.toIrType() } } + + // This patches up a frontend bug -- adapted references are mistakenly given a KFunction type. + private fun KotlinType.maybeKFunctionTypeToFunctionType() = when { + isKFunctionType -> kFunctionTypeToFunctionType(false) + isKSuspendFunctionType -> kFunctionTypeToFunctionType(true) + else -> this + } + + private fun KotlinType.kFunctionTypeToFunctionType(suspendFunction: Boolean) = createFunctionType( + statementGenerator.context.builtIns, + annotations, + null, + arguments.dropLast(1).map { it.type }, + null, + arguments.last().type, + suspendFunction + ) } \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrStatementOrigin.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrStatementOrigin.kt index c1f6072ddb1..b4c366b4369 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrStatementOrigin.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrStatementOrigin.kt @@ -89,6 +89,7 @@ interface IrStatementOrigin { object DEFAULT_VALUE : IrStatementOriginImpl("DEFAULT_VALUE") object ANONYMOUS_FUNCTION : IrStatementOriginImpl("ANONYMOUS_FUNCTION") object OBJECT_LITERAL : IrStatementOriginImpl("OBJECT_LITERAL") + object ADAPTED_FUNCTION_REFERENCE : IrStatementOriginImpl("ADAPTED_FUNCTION_REFERENCE") object INITIALIZE_PROPERTY_FROM_PARAMETER : IrStatementOriginImpl("INITIALIZE_PROPERTY_FROM_PARAMETER") object INITIALIZE_FIELD : IrStatementOriginImpl("INITIALIZE_FIELD") diff --git a/compiler/testData/codegen/box/callableReference/bound/adapted.kt b/compiler/testData/codegen/box/callableReference/bound/adapted.kt new file mode 100644 index 00000000000..926c7f7d79a --- /dev/null +++ b/compiler/testData/codegen/box/callableReference/bound/adapted.kt @@ -0,0 +1,5 @@ +class C { + fun ffff(i: Int, s: String = "OK") = s +} + +fun box(): String = 42.run(C()::ffff) diff --git a/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.txt index b425769c771..318a0636e69 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.reflect.KFunction2<.C, kotlin.Int, kotlin.Unit> origin=LAMBDA + f: FUN_EXPR 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 @@ -55,7 +55,7 @@ FILE fqName: fileName:/adaptedExtensionFunctions.kt 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.reflect.KFunction2<.C, kotlin.Int, kotlin.Unit> origin=LAMBDA + f: FUN_EXPR 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 @@ -66,7 +66,7 @@ FILE fqName: fileName:/adaptedExtensionFunctions.kt 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.reflect.KFunction2<.C, kotlin.Int, kotlin.Unit> origin=LAMBDA + f: FUN_EXPR 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 diff --git a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.txt index 1f3932a7050..e70b3788e54 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.txt @@ -23,7 +23,7 @@ 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.reflect.KFunction0 origin=LAMBDA + fn: FUN_EXPR 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 @@ -32,7 +32,7 @@ FILE fqName: fileName:/adaptedWithCoercionToUnit.kt 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.reflect.KFunction1 origin=LAMBDA + fn: FUN_EXPR 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 @@ -43,7 +43,7 @@ FILE fqName: fileName:/adaptedWithCoercionToUnit.kt 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.reflect.KFunction0 origin=LAMBDA + fn: FUN_EXPR 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 @@ -52,7 +52,7 @@ FILE fqName: fileName:/adaptedWithCoercionToUnit.kt 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.reflect.KFunction1 origin=LAMBDA + fn: FUN_EXPR 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 diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.txt index b4cf1cfa444..a832bdbd431 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.reflect.KFunction1 origin=LAMBDA + FUN_EXPR 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 @@ -132,7 +132,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.reflect.KFunction1 origin=LAMBDA + FUN_EXPR 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 diff --git a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt index 7d600fb9771..200a19c2bc3 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.reflect.KFunction1.C> origin=LAMBDA + 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 @@ -83,7 +83,7 @@ FILE fqName: fileName:/constructorWithAdaptedArguments.kt 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: FUN_EXPR type=kotlin.reflect.KFunction1.Outer.Inner> origin=LAMBDA + fn: FUN_EXPR type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:.Outer.Inner VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int BLOCK_BODY @@ -96,10 +96,10 @@ FILE fqName: fileName:/constructorWithAdaptedArguments.kt 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.reflect.KFunction1.Outer.Inner> origin=null + fn: BLOCK type=kotlin.Function1.Outer.Inner> origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.Outer [val] CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Outer' type=.Outer origin=null - FUN_EXPR type=kotlin.reflect.KFunction1.Outer.Inner> origin=LAMBDA + FUN_EXPR type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:.Outer.Inner VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.txt b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.txt index 98d8038792e..af4140b63a2 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.txt @@ -49,7 +49,7 @@ 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.reflect.KFunction0 origin=LAMBDA + 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' @@ -58,7 +58,7 @@ FILE fqName: fileName:/kt37131.kt 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.reflect.KFunction0<.C> origin=LAMBDA + 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' diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt index f2563dfc178..14bb8c072a2 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.reflect.KFunction2<.A, kotlin.Int, kotlin.Unit> origin=LAMBDA + fn: FUN_EXPR 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 @@ -74,7 +74,7 @@ FILE fqName: fileName:/unboundMemberReferenceWithAdaptedArguments.kt VALUE_PARAMETER name:a index:0 type:.A BLOCK_BODY CALL 'public final fun use2 (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.reflect.KFunction1 origin=LAMBDA + fn: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo 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 @@ -86,7 +86,7 @@ FILE fqName: fileName:/unboundMemberReferenceWithAdaptedArguments.kt FUN name:testObject visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun use2 (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.reflect.KFunction1 origin=LAMBDA + fn: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo 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 diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.txt index 04c9f496730..890de177a47 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.reflect.KFunction1 origin=LAMBDA + FUN_EXPR 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 diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt index bbb46934ec3..c163762b702 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt @@ -67,7 +67,7 @@ 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.reflect.KFunction1 origin=LAMBDA + fn: FUN_EXPR 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 @@ -78,7 +78,7 @@ FILE fqName: fileName:/withAdaptedArguments.kt 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.reflect.KFunction1 origin=LAMBDA + fn: FUN_EXPR 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 @@ -90,7 +90,7 @@ FILE fqName: fileName:/withAdaptedArguments.kt 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.reflect.KFunction1 origin=LAMBDA + fn: FUN_EXPR 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 @@ -101,7 +101,7 @@ FILE fqName: fileName:/withAdaptedArguments.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testImportedObjectMember (): kotlin.String declared in ' CALL 'public final fun use (fn: kotlin.Function1): kotlin.String declared in ' type=kotlin.String origin=null - fn: FUN_EXPR type=kotlin.reflect.KFunction1 origin=LAMBDA + fn: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:importedObjectMemberWithVarargs 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 @@ -114,7 +114,7 @@ FILE fqName: fileName:/withAdaptedArguments.kt 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.reflect.KFunction0 origin=LAMBDA + fn: FUN_EXPR 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' @@ -123,7 +123,7 @@ FILE fqName: fileName:/withAdaptedArguments.kt 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.reflect.KFunction0 origin=LAMBDA + fn: FUN_EXPR 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' diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt index a08f87a4728..f0f54d04a3b 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt @@ -21,7 +21,7 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.reflect.KFunction1 origin=LAMBDA + fn: FUN_EXPR 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 @@ -36,7 +36,7 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt VAR name:h type:.Host [val] CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Host' type=.Host origin=null CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.reflect.KFunction1 origin=LAMBDA + fn: FUN_EXPR 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 @@ -51,10 +51,10 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt VAR name:h type:.Host [var] CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Host' type=.Host origin=null CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.reflect.KFunction1 origin=null + fn: BLOCK type=kotlin.Function1 origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.Host [val] GET_VAR 'var h: .Host [var] declared in .Host.testBoundReceiverLocalVar' type=.Host origin=null - FUN_EXPR type=kotlin.reflect.KFunction1 origin=LAMBDA + FUN_EXPR 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 @@ -68,7 +68,7 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt VALUE_PARAMETER name:h index:0 type:.Host BLOCK_BODY CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.reflect.KFunction1 origin=LAMBDA + fn: FUN_EXPR 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 @@ -81,10 +81,10 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.reflect.KFunction1 origin=null + fn: BLOCK type=kotlin.Function1 origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.Host [val] CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Host' type=.Host origin=null - FUN_EXPR type=kotlin.reflect.KFunction1 origin=LAMBDA + FUN_EXPR 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 diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.txt b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.txt index a371bb3d523..10137266efc 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.reflect.KFunction2 origin=LAMBDA + fn: FUN_EXPR 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 @@ -82,7 +82,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.reflect.KFunction1, kotlin.Unit> origin=LAMBDA + fn: FUN_EXPR 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 diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.txt index b026dd34ed0..34a2eb0fff8 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.reflect.KFunction1 origin=LAMBDA + FUN_EXPR 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 diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.txt index 78d535cc076..d4c0fa43c6f 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.txt @@ -35,7 +35,7 @@ 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.reflect.KFunction0 origin=LAMBDA + FUN_EXPR 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 @@ -49,7 +49,7 @@ 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.reflect.KFunction0 origin=LAMBDA + FUN_EXPR 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 diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 49aa967a48a..a9783875771 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -2139,6 +2139,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + @TestMetadata("adapted.kt") + public void testAdapted() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/adapted.kt"); + } + public void testAllFilesPresentInBound() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/bound"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 8fba91469a5..80f10fa7d4f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -2139,6 +2139,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + @TestMetadata("adapted.kt") + public void testAdapted() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/adapted.kt"); + } + public void testAllFilesPresentInBound() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/bound"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 417f855c944..1aeceadb1bb 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -2119,6 +2119,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); } + @TestMetadata("adapted.kt") + public void testAdapted() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/adapted.kt"); + } + public void testAllFilesPresentInBound() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/bound"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functionTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functionTypes.kt index c25681247f9..d0d763391ed 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functionTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functionTypes.kt @@ -55,6 +55,9 @@ val KotlinType.isBuiltinFunctionalTypeOrSubtype: Boolean val KotlinType.isFunctionType: Boolean get() = constructor.declarationDescriptor?.getFunctionalClassKind() == FunctionClassDescriptor.Kind.Function +val KotlinType.isKFunctionType: Boolean + get() = constructor.declarationDescriptor?.getFunctionalClassKind() == FunctionClassDescriptor.Kind.KFunction + val KotlinType.isSuspendFunctionType: Boolean get() = constructor.declarationDescriptor?.getFunctionalClassKind() == FunctionClassDescriptor.Kind.SuspendFunction diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 79bd2e328dc..558982e808c 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -1549,6 +1549,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); } + @TestMetadata("adapted.kt") + public void testAdapted() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/adapted.kt"); + } + public void testAllFilesPresentInBound() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/bound"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 5a1d16fd22b..b8aff9aaa99 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -1549,6 +1549,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); } + @TestMetadata("adapted.kt") + public void testAdapted() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/adapted.kt"); + } + public void testAllFilesPresentInBound() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/bound"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); }