From 0ccd7a7e0cb84099db0bd3b9b4f3aba1faba1a53 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 7 Dec 2021 15:09:24 +0300 Subject: [PATCH] KT-47939 fun interface constructor reference should throw NPE for null --- .../backend/generators/AdapterGenerator.kt | 16 ++- .../FirBlackBoxCodegenTestGenerated.java | 6 + .../ReflectionReferencesGenerator.kt | 50 ++++--- .../kotlin/ir/builders/ExpressionHelpers.kt | 3 + .../descriptors/IrBuiltInsOverDescriptors.kt | 123 +++++++++++------- .../jetbrains/kotlin/ir/util/SymbolTable.kt | 2 +- .../funInterfaceConstructorThrowsNpe.kt | 32 +++++ ...unInterfaceConstructorReference.fir.ir.txt | 32 +++-- ...unInterfaceConstructorReference.fir.kt.txt | 16 +-- .../funInterfaceConstructorReference.ir.txt | 32 +++-- .../funInterfaceConstructorReference.kt.txt | 16 +-- .../codegen/BlackBoxCodegenTestGenerated.java | 6 + .../IrBlackBoxCodegenTestGenerated.java | 6 + .../LightAnalysisModeTestGenerated.java | 5 + .../NativeExtBlackBoxTestGenerated.java | 2 +- 15 files changed, 245 insertions(+), 102 deletions(-) create mode 100644 compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructorThrowsNpe.kt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt index 64e374a6367..11f37159f8b 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt @@ -501,7 +501,7 @@ internal class AdapterGenerator( callableReference.convertWithOffsets { startOffset: Int, endOffset: Int -> // { // fun (function: ): = - // (function) + // (function!!) // :: // } @@ -581,12 +581,16 @@ internal class AdapterGenerator( startOffset, endOffset, listOf( IrReturnImpl( - startOffset, endOffset, components.irBuiltIns.nothingType, - irAdapterFunction.symbol, + startOffset, endOffset, components.irBuiltIns.nothingType, irAdapterFunction.symbol, IrTypeOperatorCallImpl( - startOffset, endOffset, - irSamType, IrTypeOperator.SAM_CONVERSION, irSamType, - IrGetValueImpl(startOffset, endOffset, irFunctionParameter.symbol) + startOffset, endOffset, irSamType, IrTypeOperator.SAM_CONVERSION, irSamType, + IrCallImpl( + startOffset, endOffset, irFunctionType, irBuiltIns.checkNotNullSymbol, + typeArgumentsCount = 1, valueArgumentsCount = 1, origin = IrStatementOrigin.EXCLEXCL + ).apply { + putTypeArgument(0, irFunctionType) + putValueArgument(0, IrGetValueImpl(startOffset, endOffset, irFunctionParameter.symbol)) + } ) ) ) diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 684c7858a64..09a6a3ea139 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -3602,6 +3602,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT public void testFunInterfaceConstructorEquality() throws Exception { runTest("compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructorEquality.kt"); } + + @Test + @TestMetadata("funInterfaceConstructorThrowsNpe.kt") + public void testFunInterfaceConstructorThrowsNpe() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructorThrowsNpe.kt"); + } } @Nested 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 2f56a0d2c86..942b5373e20 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 @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.builtins.* import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.synthetic.FunctionInterfaceConstructorDescriptor import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET +import org.jetbrains.kotlin.ir.builders.* import org.jetbrains.kotlin.ir.declarations.DescriptorMetadataSource import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction @@ -43,6 +44,8 @@ import org.jetbrains.kotlin.resolve.ImportedFromObjectCallableDescriptor import org.jetbrains.kotlin.resolve.calls.model.* import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.TypeProjectionImpl +import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.expressions.DoubleColonLHS class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : StatementGeneratorExtension(statementGenerator) { @@ -88,7 +91,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St statementGenerator.generateCallReceiver( ktCallableReference, resolvedDescriptor, - resolvedCall.dispatchReceiver, resolvedCall.extensionReceiver,resolvedCall.contextReceivers, + resolvedCall.dispatchReceiver, resolvedCall.extensionReceiver, resolvedCall.contextReceivers, isSafe = false ).call { dispatchReceiverValue, extensionReceiverValue, _ -> generateCallableReference( @@ -119,7 +122,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St ): IrExpression { // { // fun (function: ): = - // (function) + // (function!!) // :: // } val startOffset = ktCallableReference.startOffsetSkippingComments @@ -176,23 +179,40 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St irAdapterFun.dispatchReceiverParameter = null irAdapterFun.extensionReceiverParameter = null - val irFnParameter = createAdapterParameter(startOffset, endOffset, functionParameter.name, 0, functionParameter.type) + val fnType = functionParameter.type + + val irFnParameter = createAdapterParameter(startOffset, endOffset, functionParameter.name, 0, fnType) + val irFnType = irFnParameter.type + + val checkNotNull = context.irBuiltIns.checkNotNullSymbol.descriptor + val checkNotNullSubstituted = + checkNotNull.substitute( + TypeSubstitutor.create( + mapOf(checkNotNull.typeParameters[0].typeConstructor to TypeProjectionImpl(fnType)) + ) + ) ?: throw AssertionError("Substitution failed for $checkNotNull: T=$fnType") + irAdapterFun.valueParameters = listOf(irFnParameter) irAdapterFun.body = - context.irFactory.createBlockBody( - startOffset, endOffset, - listOf( - IrReturnImpl( - startOffset, endOffset, context.irBuiltIns.nothingType, - irAdapterFun.symbol, - IrTypeOperatorCallImpl( - startOffset, endOffset, - irSamType, IrTypeOperator.SAM_CONVERSION, irSamType, - IrGetValueImpl(startOffset, endOffset, irFnParameter.symbol) - ) + IrBlockBodyBuilder( + context, + Scope(irAdapterFun.symbol), + startOffset, + endOffset + ).blockBody { + +irReturn( + irSamConversion( + irCall(context.irBuiltIns.checkNotNullSymbol).also { irCall -> + this@ReflectionReferencesGenerator.context.callToSubstitutedDescriptorMap[irCall] = + checkNotNullSubstituted + irCall.type = irFnType + irCall.putTypeArgument(0, irFnType) + irCall.putValueArgument(0, irGet(irFnParameter)) + }, + irSamType ) ) - ) + } } } } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt index 4c4afc47874..17ff92b4852 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt @@ -317,6 +317,9 @@ fun IrBuilderWithScope.irImplicitCast(argument: IrExpression, type: IrType) = fun IrBuilderWithScope.irReinterpretCast(argument: IrExpression, type: IrType) = IrTypeOperatorCallImpl(startOffset, endOffset, type, IrTypeOperator.REINTERPRET_CAST, type, argument) +fun IrBuilderWithScope.irSamConversion(argument: IrExpression, type: IrType) = + typeOperator(type, argument, IrTypeOperator.SAM_CONVERSION, type) + fun IrBuilderWithScope.irInt(value: Int, type: IrType = context.irBuiltIns.intType) = IrConstImpl.int(startOffset, endOffset, type, value) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltInsOverDescriptors.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltInsOverDescriptors.kt index b353a475143..cc12d382f73 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltInsOverDescriptors.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltInsOverDescriptors.kt @@ -96,9 +96,22 @@ class IrBuiltInsOverDescriptors( val symbol = symbolTable.declareSimpleFunctionIfNotExists(operatorDescriptor) { val operator = irFactory.createFunction( - UNDEFINED_OFFSET, UNDEFINED_OFFSET, BUILTIN_OPERATOR, it, Name.identifier(name), DescriptorVisibilities.PUBLIC, Modality.FINAL, - returnType, isInline = false, isExternal = false, isTailrec = false, isSuspend = false, - isOperator = false, isInfix = false, isExpect = false, isFakeOverride = false + UNDEFINED_OFFSET, + UNDEFINED_OFFSET, + BUILTIN_OPERATOR, + it, + Name.identifier(name), + DescriptorVisibilities.PUBLIC, + Modality.FINAL, + returnType, + isInline = false, + isExternal = false, + isTailrec = false, + isSuspend = false, + isOperator = false, + isInfix = false, + isExpect = false, + isFakeOverride = false ) operator.parent = operatorsPackageFragment operatorsPackageFragment.declarations += operator @@ -160,49 +173,53 @@ class IrBuiltInsOverDescriptors( ) } - val typeParameterSymbol = IrTypeParameterSymbolImpl(typeParameterDescriptor) - val typeParameter = irFactory.createTypeParameter( - UNDEFINED_OFFSET, UNDEFINED_OFFSET, BUILTIN_OPERATOR, typeParameterSymbol, Name.identifier("T0"), 0, true, Variance.INVARIANT - ).apply { - superTypes += anyType - } + return symbolTable.declareSimpleFunctionIfNotExists(operatorDescriptor) { operatorSymbol -> + val typeParameter = symbolTable.declareGlobalTypeParameter( + UNDEFINED_OFFSET, UNDEFINED_OFFSET, + BUILTIN_OPERATOR, + typeParameterDescriptor + ).apply { + superTypes += anyType + } + val typeParameterSymbol = typeParameter.symbol - val returnIrType = IrSimpleTypeBuilder().run { - classifier = typeParameterSymbol - kotlinType = returnKotlinType - hasQuestionMark = false - buildSimpleType() - } + val returnIrType = IrSimpleTypeBuilder().run { + classifier = typeParameterSymbol + kotlinType = returnKotlinType + hasQuestionMark = false + buildSimpleType() + } - val valueIrType = IrSimpleTypeBuilder().run { - classifier = typeParameterSymbol - kotlinType = valueKotlinType - hasQuestionMark = true - buildSimpleType() - } + val valueIrType = IrSimpleTypeBuilder().run { + classifier = typeParameterSymbol + kotlinType = valueKotlinType + hasQuestionMark = true + buildSimpleType() + } - return symbolTable.declareSimpleFunctionIfNotExists(operatorDescriptor) { - val operator = irFactory.createFunction( - UNDEFINED_OFFSET, UNDEFINED_OFFSET, BUILTIN_OPERATOR, it, name, DescriptorVisibilities.PUBLIC, Modality.FINAL, returnIrType, + irFactory.createFunction( + UNDEFINED_OFFSET, UNDEFINED_OFFSET, BUILTIN_OPERATOR, + operatorSymbol, name, + DescriptorVisibilities.PUBLIC, Modality.FINAL, + returnIrType, isInline = false, isExternal = false, isTailrec = false, isSuspend = false, isOperator = false, isInfix = false, isExpect = false, isFakeOverride = false - ) - operator.parent = operatorsPackageFragment - operatorsPackageFragment.declarations += operator + ).also { operator -> + operator.parent = operatorsPackageFragment + operatorsPackageFragment.declarations += operator - val valueParameterSymbol = IrValueParameterSymbolImpl(valueParameterDescriptor) - val valueParameter = irFactory.createValueParameter( - UNDEFINED_OFFSET, UNDEFINED_OFFSET, BUILTIN_OPERATOR, valueParameterSymbol, Name.identifier("arg0"), 0, - valueIrType, null, isCrossinline = false, isNoinline = false, isHidden = false, isAssignable = false - ) + val valueParameterSymbol = IrValueParameterSymbolImpl(valueParameterDescriptor) + val valueParameter = irFactory.createValueParameter( + UNDEFINED_OFFSET, UNDEFINED_OFFSET, BUILTIN_OPERATOR, valueParameterSymbol, Name.identifier("arg0"), 0, + valueIrType, null, isCrossinline = false, isNoinline = false, isHidden = false, isAssignable = false + ) - valueParameter.parent = operator - typeParameter.parent = operator + valueParameter.parent = operator + typeParameter.parent = operator - operator.valueParameters += valueParameter - operator.typeParameters += typeParameter - - operator + operator.valueParameters += valueParameter + operator.typeParameters += typeParameter + } }.symbol } @@ -265,6 +282,7 @@ class IrBuiltInsOverDescriptors( val string = builtIns.stringType override val stringType = string.toIrType() override val stringClass = builtIns.string.toIrSymbol() + // TODO: check if correct override val charSequenceClass = findClass(Name.identifier("CharSequence"), "kotlin")!! @@ -341,7 +359,8 @@ class IrBuiltInsOverDescriptors( override val doubleArray = builtIns.getPrimitiveArrayClassDescriptor(PrimitiveType.DOUBLE).toIrSymbol() override val booleanArray = builtIns.getPrimitiveArrayClassDescriptor(PrimitiveType.BOOLEAN).toIrSymbol() - override val primitiveArraysToPrimitiveTypes = PrimitiveType.values().associate { builtIns.getPrimitiveArrayClassDescriptor(it).toIrSymbol() to it } + override val primitiveArraysToPrimitiveTypes = + PrimitiveType.values().associate { builtIns.getPrimitiveArrayClassDescriptor(it).toIrSymbol() to it } override val primitiveTypesToPrimitiveArrays = primitiveArraysToPrimitiveTypes.map { (k, v) -> v to k }.toMap() override val primitiveArrayElementTypes = primitiveArraysToPrimitiveTypes.mapValues { primitiveTypeToIrType[it.value] } override val primitiveArrayForType = primitiveArrayElementTypes.asSequence().associate { it.value to it.key } @@ -353,16 +372,24 @@ class IrBuiltInsOverDescriptors( }.toMap() override val lessFunByOperandType = primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(BuiltInOperatorNames.LESS) - override val lessOrEqualFunByOperandType = primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(BuiltInOperatorNames.LESS_OR_EQUAL) - override val greaterOrEqualFunByOperandType = primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(BuiltInOperatorNames.GREATER_OR_EQUAL) - override val greaterFunByOperandType = primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(BuiltInOperatorNames.GREATER) + override val lessOrEqualFunByOperandType = + primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(BuiltInOperatorNames.LESS_OR_EQUAL) + override val greaterOrEqualFunByOperandType = + primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(BuiltInOperatorNames.GREATER_OR_EQUAL) + override val greaterFunByOperandType = + primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(BuiltInOperatorNames.GREATER) override val ieee754equalsFunByOperandType = primitiveFloatingPointIrTypes.map { - it.classifierOrFail to defineOperator(BuiltInOperatorNames.IEEE754_EQUALS, booleanType, listOf(it.makeNullable(), it.makeNullable())) + it.classifierOrFail to defineOperator( + BuiltInOperatorNames.IEEE754_EQUALS, + booleanType, + listOf(it.makeNullable(), it.makeNullable()) + ) }.toMap() - val booleanNot = builtIns.boolean.unsubstitutedMemberScope.getContributedFunctions(Name.identifier("not"), NoLookupLocation.FROM_BACKEND).single() + val booleanNot = + builtIns.boolean.unsubstitutedMemberScope.getContributedFunctions(Name.identifier("not"), NoLookupLocation.FROM_BACKEND).single() override val booleanNotSymbol = symbolTable.referenceSimpleFunction(booleanNot) override val eqeqeqSymbol = defineOperator(BuiltInOperatorNames.EQEQEQ, booleanType, listOf(anyNType, anyNType)) @@ -371,8 +398,10 @@ class IrBuiltInsOverDescriptors( override val throwIseSymbol = defineOperator(BuiltInOperatorNames.THROW_ISE, nothingType, listOf()) override val andandSymbol = defineOperator(BuiltInOperatorNames.ANDAND, booleanType, listOf(booleanType, booleanType)) override val ororSymbol = defineOperator(BuiltInOperatorNames.OROR, booleanType, listOf(booleanType, booleanType)) - override val noWhenBranchMatchedExceptionSymbol = defineOperator(BuiltInOperatorNames.NO_WHEN_BRANCH_MATCHED_EXCEPTION, nothingType, listOf()) - override val illegalArgumentExceptionSymbol = defineOperator(BuiltInOperatorNames.ILLEGAL_ARGUMENT_EXCEPTION, nothingType, listOf(stringType)) + override val noWhenBranchMatchedExceptionSymbol = + defineOperator(BuiltInOperatorNames.NO_WHEN_BRANCH_MATCHED_EXCEPTION, nothingType, listOf()) + override val illegalArgumentExceptionSymbol = + defineOperator(BuiltInOperatorNames.ILLEGAL_ARGUMENT_EXCEPTION, nothingType, listOf(stringType)) override val checkNotNullSymbol = defineCheckNotNullOperator() @@ -476,7 +505,7 @@ class IrBuiltInsOverDescriptors( } } - private fun getFunctionsByKey( + private fun getFunctionsByKey( name: Name, vararg packageNameSegments: String, makeKey: (SimpleFunctionDescriptor) -> T? diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt index 96290161a44..cc3e73cc467 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt @@ -1129,7 +1129,7 @@ fun SymbolTable.noUnboundLeft(message: String) { assert(unbound.isEmpty()) { "$message\n" + unbound.joinToString("\n") { - "$it ${it.signature?.toString() ?: "(NON-PUBLIC API)"}: ${it.descriptor}" + "${it::class.simpleName} $it ${it.signature?.toString() ?: "(NON-PUBLIC API)"}: ${it.descriptor}" } } } diff --git a/compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructorThrowsNpe.kt b/compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructorThrowsNpe.kt new file mode 100644 index 00000000000..ae226ec7e9b --- /dev/null +++ b/compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructorThrowsNpe.kt @@ -0,0 +1,32 @@ +// !LANGUAGE: +KotlinFunInterfaceConstructorReference + +// WITH_RUNTIME +// TARGET_BACKEND: JVM + +// DONT_TARGET_EXACT_BACKEND: JVM +// ^ old JVM BE generates bogus code + +// FILE: funInterfaceConstructorThrowsNpe.kt + +fun interface KSupplier { + fun get(): T +} + +val ks: (() -> String) -> KSupplier = + ::KSupplier + +fun box(): String { + try { + ks(J.fn) + return "ks(null) should throw NPE" + } catch (e: NullPointerException) { + return "OK" + } +} + +// FILE: J.java +import kotlin.jvm.functions.Function0; + +public class J { + public static Function0 fn = null; +} diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt index df07c6c07c4..a909927ac5c 100644 --- a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt @@ -65,7 +65,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'function: kotlin.Function0 declared in .test1.KRunnable' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL + : kotlin.Function0 + arg0: GET_VAR 'function: kotlin.Function0 declared in .test1.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1' type=kotlin.reflect.KFunction1, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test1a visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction1, .KRunnable> BLOCK_BODY @@ -76,7 +78,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1a' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'function: kotlin.Function0 declared in .test1a.KRunnable' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL + : kotlin.Function0 + arg0: GET_VAR 'function: kotlin.Function0 declared in .test1a.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1a' type=kotlin.reflect.KFunction1, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test1b visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction<.KRunnable> BLOCK_BODY @@ -87,7 +91,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1b' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'function: kotlin.Function0 declared in .test1b.KRunnable' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL + : kotlin.Function0 + arg0: GET_VAR 'function: kotlin.Function0 declared in .test1b.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1b' type=kotlin.reflect.KFunction1, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KSupplier> BLOCK_BODY @@ -98,7 +104,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2' TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier - GET_VAR 'function: kotlin.Function0 declared in .test2.KSupplier' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL + : kotlin.Function0 + arg0: GET_VAR 'function: kotlin.Function0 declared in .test2.KSupplier' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2' type=kotlin.reflect.KFunction1, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test2a visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KSupplier> BLOCK_BODY @@ -109,7 +117,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2a' TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier - GET_VAR 'function: kotlin.Function0 declared in .test2a.KSupplier' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL + : kotlin.Function0 + arg0: GET_VAR 'function: kotlin.Function0 declared in .test2a.KSupplier' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2a' type=kotlin.reflect.KFunction1, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KConsumer> BLOCK_BODY @@ -120,7 +130,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3' TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - GET_VAR 'function: kotlin.Function1 declared in .test3.KConsumer' type=kotlin.Function1 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function1 origin=EXCLEXCL + : kotlin.Function1 + arg0: GET_VAR 'function: kotlin.Function1 declared in .test3.KConsumer' type=kotlin.Function1 origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3' type=kotlin.reflect.KFunction1, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test3a visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KConsumer> BLOCK_BODY @@ -131,7 +143,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3a' TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - GET_VAR 'function: kotlin.Function1 declared in .test3a.KConsumer' type=kotlin.Function1 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function1 origin=EXCLEXCL + : kotlin.Function1 + arg0: GET_VAR 'function: kotlin.Function1 declared in .test3a.KConsumer' type=kotlin.Function1 origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3a' type=kotlin.reflect.KFunction1, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test3b visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction<.KConsumer> BLOCK_BODY @@ -142,5 +156,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3b' TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - GET_VAR 'function: kotlin.Function1 declared in .test3b.KConsumer' type=kotlin.Function1 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function1 origin=EXCLEXCL + : kotlin.Function1 + arg0: GET_VAR 'function: kotlin.Function1 declared in .test3b.KConsumer' type=kotlin.Function1 origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3b' type=kotlin.reflect.KFunction1, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.kt.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.kt.txt index a111cd7808b..5bd3ad647aa 100644 --- a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.kt.txt @@ -19,7 +19,7 @@ fun interface KConsumer { fun test1(): KFunction1, KRunnable> { return { // BLOCK local fun KRunnable(function: Function0): KRunnable { - return function /*-> KRunnable */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KRunnable */ } ::KRunnable @@ -29,7 +29,7 @@ fun test1(): KFunction1, KRunnable> { fun test1a(): KFunction1, KRunnable> { return { // BLOCK local fun KRunnable(function: Function0): KRunnable { - return function /*-> KRunnable */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KRunnable */ } ::KRunnable @@ -39,7 +39,7 @@ fun test1a(): KFunction1, KRunnable> { fun test1b(): KFunction { return { // BLOCK local fun KRunnable(function: Function0): KRunnable { - return function /*-> KRunnable */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KRunnable */ } ::KRunnable @@ -49,7 +49,7 @@ fun test1b(): KFunction { fun test2(): Function1, KSupplier> { return { // BLOCK local fun KSupplier(function: Function0): KSupplier { - return function /*-> KSupplier */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KSupplier */ } ::KSupplier @@ -59,7 +59,7 @@ fun test2(): Function1, KSupplier> { fun test2a(): Function1, KSupplier> { return { // BLOCK local fun KSupplier(function: Function0): KSupplier { - return function /*-> KSupplier */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KSupplier */ } ::KSupplier @@ -69,7 +69,7 @@ fun test2a(): Function1, KSupplier> { fun test3(): Function1, KConsumer> { return { // BLOCK local fun KConsumer(function: Function1): KConsumer { - return function /*-> KConsumer */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KConsumer */ } ::KConsumer @@ -79,7 +79,7 @@ fun test3(): Function1, KConsumer> { fun test3a(): Function1, KConsumer> { return { // BLOCK local fun KConsumer(function: Function1): KConsumer { - return function /*-> KConsumer */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KConsumer */ } ::KConsumer @@ -89,7 +89,7 @@ fun test3a(): Function1, KConsumer> { fun test3b(): KFunction> { return { // BLOCK local fun KConsumer(function: Function1): KConsumer { - return function /*-> KConsumer */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KConsumer */ } ::KConsumer diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.ir.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.ir.txt index 13c14ed2405..305bead6428 100644 --- a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.ir.txt +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.ir.txt @@ -65,7 +65,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'function: kotlin.Function0 declared in .test1.KRunnable' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=null + : kotlin.Function0 + arg0: GET_VAR 'function: kotlin.Function0 declared in .test1.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test1a visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> BLOCK_BODY @@ -76,7 +78,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1a' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'function: kotlin.Function0 declared in .test1a.KRunnable' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=null + : kotlin.Function0 + arg0: GET_VAR 'function: kotlin.Function0 declared in .test1a.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1a' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test1b visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction<.KRunnable> BLOCK_BODY @@ -87,7 +91,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1b' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'function: kotlin.Function0 declared in .test1b.KRunnable' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=null + : kotlin.Function0 + arg0: GET_VAR 'function: kotlin.Function0 declared in .test1b.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1b' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KSupplier> BLOCK_BODY @@ -98,7 +104,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2' TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier - GET_VAR 'function: kotlin.Function0 declared in .test2.KSupplier' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=null + : kotlin.Function0 + arg0: GET_VAR 'function: kotlin.Function0 declared in .test2.KSupplier' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test2a visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KSupplier> BLOCK_BODY @@ -109,7 +117,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2a' TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier - GET_VAR 'function: kotlin.Function0 declared in .test2a.KSupplier' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=null + : kotlin.Function0 + arg0: GET_VAR 'function: kotlin.Function0 declared in .test2a.KSupplier' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2a' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KConsumer> BLOCK_BODY @@ -120,7 +130,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3' TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null + : kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> + arg0: GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test3a visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KConsumer> BLOCK_BODY @@ -131,7 +143,9 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3a' TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3a.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null + : kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> + arg0: GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3a.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3a' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test3b visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction<.KConsumer> BLOCK_BODY @@ -142,5 +156,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3b' TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3b.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null + : kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> + arg0: GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3b.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3b' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt index bbebf64d22b..84888202536 100644 --- a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt @@ -19,7 +19,7 @@ typealias KCS = KConsumer fun test1(): KFunction1<@ParameterName(name = "function") Function0, KRunnable> { return { // BLOCK local fun KRunnable(function: Function0): KRunnable { - return function /*-> KRunnable */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KRunnable */ } ::KRunnable @@ -29,7 +29,7 @@ fun test1(): KFunction1<@ParameterName(name = "function") Function0, KRunn fun test1a(): KFunction1<@ParameterName(name = "function") Function0, KRunnable> { return { // BLOCK local fun KRunnable(function: Function0): KRunnable { - return function /*-> KRunnable */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KRunnable */ } ::KRunnable @@ -39,7 +39,7 @@ fun test1a(): KFunction1<@ParameterName(name = "function") Function0, KRun fun test1b(): KFunction { return { // BLOCK local fun KRunnable(function: Function0): KRunnable { - return function /*-> KRunnable */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KRunnable */ } ::KRunnable @@ -49,7 +49,7 @@ fun test1b(): KFunction { fun test2(): Function1, KSupplier> { return { // BLOCK local fun KSupplier(function: Function0): KSupplier { - return function /*-> KSupplier */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KSupplier */ } ::KSupplier @@ -59,7 +59,7 @@ fun test2(): Function1, KSupplier> { fun test2a(): Function1, KSupplier> { return { // BLOCK local fun KSupplier(function: Function0): KSupplier { - return function /*-> KSupplier */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KSupplier */ } ::KSupplier @@ -69,7 +69,7 @@ fun test2a(): Function1, KSupplier> { fun test3(): Function1, KConsumer> { return { // BLOCK local fun KConsumer(function: Function1<@ParameterName(name = "x") String, Unit>): KConsumer { - return function /*-> KConsumer */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KConsumer */ } ::KConsumer @@ -79,7 +79,7 @@ fun test3(): Function1, KConsumer> { fun test3a(): Function1, KConsumer> { return { // BLOCK local fun KConsumer(function: Function1<@ParameterName(name = "x") String, Unit>): KConsumer { - return function /*-> KConsumer */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KConsumer */ } ::KConsumer @@ -89,7 +89,7 @@ fun test3a(): Function1, KConsumer> { fun test3b(): KFunction> { return { // BLOCK local fun KConsumer(function: Function1<@ParameterName(name = "x") String, Unit>): KConsumer { - return function /*-> KConsumer */ + return CHECK_NOT_NULL>(arg0 = function) /*-> KConsumer */ } ::KConsumer diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 05efc1895cf..335e4d6a052 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -3518,6 +3518,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testFunInterfaceConstructor() throws Exception { runTest("compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructor.kt"); } + + @Test + @TestMetadata("funInterfaceConstructorThrowsNpe.kt") + public void testFunInterfaceConstructorThrowsNpe() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructorThrowsNpe.kt"); + } } @Nested diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 459cf8912a6..c3435b7b27e 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -3602,6 +3602,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testFunInterfaceConstructorEquality() throws Exception { runTest("compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructorEquality.kt"); } + + @Test + @TestMetadata("funInterfaceConstructorThrowsNpe.kt") + public void testFunInterfaceConstructorThrowsNpe() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructorThrowsNpe.kt"); + } } @Nested diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index d57eeec5474..0389bf697f1 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -3078,6 +3078,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructor.kt"); } + @TestMetadata("funInterfaceConstructorThrowsNpe.kt") + public void ignoreFunInterfaceConstructorThrowsNpe() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructorThrowsNpe.kt"); + } + private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java index d7d837691b7..32f3a3f81eb 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java @@ -2514,7 +2514,7 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest { public class FunInterfaceConstructor { @Test public void testAllFilesPresentInFunInterfaceConstructor() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/funInterfaceConstructor"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference/funInterfaceConstructor"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } @Test