FIR2IR KT-47939 callable references to fun interface constructors

This commit is contained in:
Dmitry Petrov
2021-11-29 18:51:01 +03:00
committed by TeamCityServer
parent f55f880726
commit 11daed8b01
7 changed files with 215 additions and 45 deletions
@@ -7,10 +7,7 @@ package org.jetbrains.kotlin.fir.backend.generators
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.fir.backend.Fir2IrComponents
import org.jetbrains.kotlin.fir.backend.Fir2IrConversionScope
import org.jetbrains.kotlin.fir.backend.FirMetadataSource
import org.jetbrains.kotlin.fir.backend.convertWithOffsets
import org.jetbrains.kotlin.fir.backend.*
import org.jetbrains.kotlin.fir.declarations.FirFunction
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
@@ -21,23 +18,18 @@ import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference
import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.resolve.calls.FirFakeArgumentForCallableReference
import org.jetbrains.kotlin.fir.resolve.calls.ResolvedCallArgument
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.ir.builders.declarations.UNDEFINED_PARAMETER_INDEX
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.IrBlock
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrGetValue
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.expressions.*
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.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.isUnit
import org.jetbrains.kotlin.ir.types.typeOrNull
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.name.Name
@@ -500,4 +492,101 @@ internal class AdapterGenerator(
}
return irCall
}
fun generateFunInterfaceConstructorReference(
callableReference: FirCallableReferenceAccess,
callableSymbol: FirFunctionSymbol<*>,
irReferenceType: IrType
): IrExpression =
callableReference.convertWithOffsets { startOffset: Int, endOffset: Int ->
// {
// fun <ADAPTER_FUN>(function: <FUN_TYPE>): <FUN_INTERFACE_TYPE> =
// <FUN_INTERFACE_TYPE>(function)
// ::<ADAPTER_FUN>
// }
val irAdapterFun = generateFunInterfaceConstructorAdapter(startOffset, endOffset, callableSymbol, irReferenceType)
val irAdapterRef = IrFunctionReferenceImpl(
startOffset, endOffset,
type = irReferenceType,
symbol = irAdapterFun.symbol,
typeArgumentsCount = irAdapterFun.typeParameters.size,
valueArgumentsCount = irAdapterFun.valueParameters.size,
reflectionTarget = irAdapterFun.symbol,
origin = IrStatementOrigin.FUN_INTERFACE_CONSTRUCTOR_REFERENCE
)
IrBlockImpl(
startOffset, endOffset,
irReferenceType,
IrStatementOrigin.FUN_INTERFACE_CONSTRUCTOR_REFERENCE,
listOf(
irAdapterFun,
irAdapterRef
)
)
}
private fun IrSimpleType.getArgumentTypeAt(index: Int): IrType {
val irTypeArgument = this.arguments[index] as? IrTypeProjection
?: throw AssertionError("Type projection expected at argument $index: ${this.render()}")
return irTypeArgument.type
}
private fun generateFunInterfaceConstructorAdapter(
startOffset: Int,
endOffset: Int,
callableSymbol: FirFunctionSymbol<*>,
irReferenceType: IrType
): IrSimpleFunction {
// Here irReferenceType is always kotlin.reflect.KFunction1<FUN_TYPE, FUN_INTERFACE_TYPE>
val irSimpleReferenceType = irReferenceType as? IrSimpleType
?: throw AssertionError("Class type expected: ${irReferenceType.render()}")
val irSamType = irSimpleReferenceType.getArgumentTypeAt(1)
val irFunctionType = irSimpleReferenceType.getArgumentTypeAt(0)
val functionParameter = callableSymbol.valueParameterSymbols.singleOrNull()
?: throw AssertionError("Single value parameter expected: ${callableSymbol.valueParameterSymbols}")
return irFactory.createFunction(
startOffset, endOffset,
IrDeclarationOrigin.ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR,
IrSimpleFunctionSymbolImpl(),
callableSymbol.name,
DescriptorVisibilities.LOCAL,
Modality.FINAL,
irSamType,
isInline = false,
isExternal = false,
isTailrec = false,
isSuspend = true,
isOperator = false,
isInfix = false,
isExpect = false,
isFakeOverride = false
).also { irAdapterFunction ->
symbolTable.enterScope(irAdapterFunction)
irAdapterFunction.dispatchReceiverParameter = null
irAdapterFunction.extensionReceiverParameter = null
val irFunctionParameter = createAdapterParameter(
irAdapterFunction,
functionParameter.name,
0,
irFunctionType,
IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE
)
irAdapterFunction.valueParameters = listOf(irFunctionParameter)
irAdapterFunction.body = irFactory.createExpressionBody(
startOffset, endOffset,
IrTypeOperatorCallImpl(
startOffset, endOffset,
irSamType, IrTypeOperator.SAM_CONVERSION, irSamType,
IrGetValueImpl(startOffset, endOffset, irFunctionParameter.symbol)
)
)
symbolTable.leaveScope(irAdapterFunction)
irAdapterFunction.parent = conversionScope.parent()!!
}
}
}
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference
import org.jetbrains.kotlin.fir.references.impl.FirReferencePlaceholderForResolvedAnnotations
import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.resolve.FirSamResolverImpl
import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticFunctionSymbol
import org.jetbrains.kotlin.fir.resolve.calls.getExpectedType
import org.jetbrains.kotlin.fir.resolve.calls.isFunctional
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
@@ -43,6 +44,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.dump
import org.jetbrains.kotlin.ir.util.isFunctionTypeOrSubtype
import org.jetbrains.kotlin.ir.util.isInterface
import org.jetbrains.kotlin.ir.util.render
@@ -70,10 +72,22 @@ class CallAndReferenceGenerator(
callableReferenceAccess: FirCallableReferenceAccess,
explicitReceiverExpression: IrExpression?
): IrExpression {
val type = callableReferenceAccess.typeRef.toIrType()
val callableSymbol = callableReferenceAccess.calleeReference.toResolvedCallableSymbol()
if (callableSymbol?.origin == FirDeclarationOrigin.SamConstructor) {
assert(explicitReceiverExpression == null) {
"Fun interface constructor reference should be unbound: ${explicitReceiverExpression?.dump()}"
}
return adapterGenerator.generateFunInterfaceConstructorReference(
callableReferenceAccess,
callableSymbol as FirSyntheticFunctionSymbol,
type
)
}
val symbol = callableReferenceAccess.calleeReference.toSymbolForCall(
callableReferenceAccess.dispatchReceiver, session, classifierStorage, declarationStorage, conversionScope
)
val type = callableReferenceAccess.typeRef.toIrType()
// val x by y ->
// val `x$delegate` = y
// val x get() = `x$delegate`.getValue(this, ::x)
@@ -59,32 +59,70 @@ FILE fqName:<root> fileName:/funInterfaceConstructorReference.kt
FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, <root>.KRunnable>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, <root>.KRunnable> declared in <root>'
FUNCTION_REFERENCE 'public final fun KRunnable (function: kotlin.Function0<kotlin.Unit>): <root>.KRunnable declared in <root>' type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, <root>.KRunnable> origin=null reflectionTarget=<same>
BLOCK type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, <root>.KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KRunnable visibility:local modality:FINAL <> (function:kotlin.Function0<kotlin.Unit>) returnType:<root>.KRunnable [suspend]
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0<kotlin.Unit>
EXPRESSION_BODY
TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
GET_VAR 'function: kotlin.Function0<kotlin.Unit> declared in <root>.test1.KRunnable' type=kotlin.Function0<kotlin.Unit> origin=null
FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0<kotlin.Unit>): <root>.KRunnable [suspend] declared in <root>.test1' type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, <root>.KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
FUN name:test1a visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, <root>.KRunnable>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test1a (): kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, <root>.KRunnable> declared in <root>'
FUNCTION_REFERENCE 'public final fun KRunnable (function: kotlin.Function0<kotlin.Unit>): <root>.KRunnable declared in <root>' type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, <root>.KRunnable> origin=null reflectionTarget=<same>
FUN name:test1b visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction<java.lang.Runnable>
BLOCK type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, <root>.KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KRunnable visibility:local modality:FINAL <> (function:kotlin.Function0<kotlin.Unit>) returnType:<root>.KRunnable [suspend]
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0<kotlin.Unit>
EXPRESSION_BODY
TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
GET_VAR 'function: kotlin.Function0<kotlin.Unit> declared in <root>.test1a.KRunnable' type=kotlin.Function0<kotlin.Unit> origin=null
FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0<kotlin.Unit>): <root>.KRunnable [suspend] declared in <root>.test1a' type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, <root>.KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
FUN name:test1b visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction<<root>.KRunnable>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test1b (): kotlin.reflect.KFunction<java.lang.Runnable> declared in <root>'
FUNCTION_REFERENCE 'public final fun Runnable (function: kotlin.Function0<kotlin.Unit>): java.lang.Runnable declared in java.lang' type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, java.lang.Runnable> origin=null reflectionTarget=<same>
RETURN type=kotlin.Nothing from='public final fun test1b (): kotlin.reflect.KFunction<<root>.KRunnable> declared in <root>'
BLOCK type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, <root>.KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KRunnable visibility:local modality:FINAL <> (function:kotlin.Function0<kotlin.Unit>) returnType:<root>.KRunnable [suspend]
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0<kotlin.Unit>
EXPRESSION_BODY
TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
GET_VAR 'function: kotlin.Function0<kotlin.Unit> declared in <root>.test1b.KRunnable' type=kotlin.Function0<kotlin.Unit> origin=null
FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0<kotlin.Unit>): <root>.KRunnable [suspend] declared in <root>.test1b' type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.Unit>, <root>.KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Function1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.Function1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> declared in <root>'
FUNCTION_REFERENCE 'public final fun KSupplier <T> (function: kotlin.Function0<T of <root>.KSupplier>): <root>.KSupplier<T of <root>.KSupplier> declared in <root>' type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> origin=null reflectionTarget=<same>
<T>: kotlin.String
BLOCK type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KSupplier visibility:local modality:FINAL <> (function:kotlin.Function0<kotlin.String>) returnType:<root>.KSupplier<kotlin.String> [suspend]
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0<kotlin.String>
EXPRESSION_BODY
TYPE_OP type=<root>.KSupplier<kotlin.String> origin=SAM_CONVERSION typeOperand=<root>.KSupplier<kotlin.String>
GET_VAR 'function: kotlin.Function0<kotlin.String> declared in <root>.test2.KSupplier' type=kotlin.Function0<kotlin.String> origin=null
FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0<kotlin.String>): <root>.KSupplier<kotlin.String> [suspend] declared in <root>.test2' type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
FUN name:test2a visibility:public modality:FINAL <> () returnType:kotlin.Function1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test2a (): kotlin.Function1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> declared in <root>'
FUNCTION_REFERENCE 'public final fun KSupplier <T> (function: kotlin.Function0<T of <root>.KSupplier>): <root>.KSupplier<T of <root>.KSupplier> declared in <root>' type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> origin=null reflectionTarget=<same>
<T>: kotlin.String
BLOCK type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KSupplier visibility:local modality:FINAL <> (function:kotlin.Function0<kotlin.String>) returnType:<root>.KSupplier<kotlin.String> [suspend]
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0<kotlin.String>
EXPRESSION_BODY
TYPE_OP type=<root>.KSupplier<kotlin.String> origin=SAM_CONVERSION typeOperand=<root>.KSupplier<kotlin.String>
GET_VAR 'function: kotlin.Function0<kotlin.String> declared in <root>.test2a.KSupplier' type=kotlin.Function0<kotlin.String> origin=null
FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0<kotlin.String>): <root>.KSupplier<kotlin.String> [suspend] declared in <root>.test2a' type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Function1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test3 (): kotlin.Function1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> declared in <root>'
FUNCTION_REFERENCE 'public final fun KConsumer <T> (function: kotlin.Function1<T of <root>.KConsumer, kotlin.Unit>): <root>.KConsumer<T of <root>.KConsumer> declared in <root>' type=kotlin.reflect.KFunction1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> origin=null reflectionTarget=<same>
<T>: kotlin.String
BLOCK type=kotlin.reflect.KFunction1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KConsumer visibility:local modality:FINAL <> (function:kotlin.Function1<kotlin.String, kotlin.Unit>) returnType:<root>.KConsumer<kotlin.String> [suspend]
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function1<kotlin.String, kotlin.Unit>
EXPRESSION_BODY
TYPE_OP type=<root>.KConsumer<kotlin.String> origin=SAM_CONVERSION typeOperand=<root>.KConsumer<kotlin.String>
GET_VAR 'function: kotlin.Function1<kotlin.String, kotlin.Unit> declared in <root>.test3.KConsumer' type=kotlin.Function1<kotlin.String, kotlin.Unit> origin=null
FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1<kotlin.String, kotlin.Unit>): <root>.KConsumer<kotlin.String> [suspend] declared in <root>.test3' type=kotlin.reflect.KFunction1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
FUN name:test3a visibility:public modality:FINAL <> () returnType:kotlin.Function1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test3a (): kotlin.Function1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> declared in <root>'
FUNCTION_REFERENCE 'public final fun KConsumer <T> (function: kotlin.Function1<T of <root>.KConsumer, kotlin.Unit>): <root>.KConsumer<T of <root>.KConsumer> declared in <root>' type=kotlin.reflect.KFunction1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> origin=null reflectionTarget=<same>
<T>: kotlin.String
BLOCK type=kotlin.reflect.KFunction1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KConsumer visibility:local modality:FINAL <> (function:kotlin.Function1<kotlin.String, kotlin.Unit>) returnType:<root>.KConsumer<kotlin.String> [suspend]
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function1<kotlin.String, kotlin.Unit>
EXPRESSION_BODY
TYPE_OP type=<root>.KConsumer<kotlin.String> origin=SAM_CONVERSION typeOperand=<root>.KConsumer<kotlin.String>
GET_VAR 'function: kotlin.Function1<kotlin.String, kotlin.Unit> declared in <root>.test3a.KConsumer' type=kotlin.Function1<kotlin.String, kotlin.Unit> origin=null
FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1<kotlin.String, kotlin.Unit>): <root>.KConsumer<kotlin.String> [suspend] declared in <root>.test3a' type=kotlin.reflect.KFunction1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
@@ -17,29 +17,58 @@ fun interface KConsumer<T : Any?> {
}
fun test1(): KFunction1<Function0<Unit>, KRunnable> {
return ::KRunnable
return { // BLOCK
local suspend fun KRunnable(function: Function0<Unit>): KRunnable function /*-> KRunnable */
::KRunnable
}
}
fun test1a(): KFunction1<Function0<Unit>, KRunnable> {
return ::KRunnable
return { // BLOCK
local suspend fun KRunnable(function: Function0<Unit>): KRunnable function /*-> KRunnable */
::KRunnable
}
}
fun test1b(): KFunction<Runnable> {
return ::Runnable
fun test1b(): KFunction<KRunnable> {
return { // BLOCK
local suspend fun KRunnable(function: Function0<Unit>): KRunnable function /*-> KRunnable */
::KRunnable
}
}
fun test2(): Function1<Function0<String>, KSupplier<String>> {
return ::KSupplier/*<String>()*/
return { // BLOCK
local suspend fun KSupplier(function: Function0<String>): KSupplier<String> function /*-> KSupplier<String> */
::KSupplier
}
}
fun test2a(): Function1<Function0<String>, KSupplier<String>> {
return ::KSupplier/*<String>()*/
return { // BLOCK
local suspend fun KSupplier(function: Function0<String>): KSupplier<String> function /*-> KSupplier<String> */
::KSupplier
}
}
fun test3(): Function1<Function1<String, Unit>, KConsumer<String>> {
return ::KConsumer/*<String>()*/
return { // BLOCK
local suspend fun KConsumer(function: Function1<String, Unit>): KConsumer<String> function /*-> KConsumer<String> */
::KConsumer
}
}
fun test3a(): Function1<Function1<String, Unit>, KConsumer<String>> {
return ::KConsumer/*<String>()*/
return { // BLOCK
local suspend fun KConsumer(function: Function1<String, Unit>): KConsumer<String> function /*-> KConsumer<String> */
::KConsumer
}
}
@@ -76,16 +76,16 @@ FILE fqName:<root> fileName:/funInterfaceConstructorReference.kt
TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
GET_VAR 'function: kotlin.Function0<kotlin.Unit> declared in <root>.test1a.KRunnable' type=kotlin.Function0<kotlin.Unit> origin=null
FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0<kotlin.Unit>): <root>.KRunnable declared in <root>.test1a' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0<kotlin.Unit>, <root>.KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
FUN name:test1b visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction<java.lang.Runnable>
FUN name:test1b visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction<<root>.KRunnable>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test1b (): kotlin.reflect.KFunction<java.lang.Runnable> declared in <root>'
BLOCK type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0<kotlin.Unit>, java.lang.Runnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:Runnable visibility:local modality:FINAL <> (function:kotlin.Function0<kotlin.Unit>) returnType:java.lang.Runnable
RETURN type=kotlin.Nothing from='public final fun test1b (): kotlin.reflect.KFunction<<root>.KRunnable> declared in <root>'
BLOCK type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0<kotlin.Unit>, <root>.KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KRunnable visibility:local modality:FINAL <> (function:kotlin.Function0<kotlin.Unit>) returnType:<root>.KRunnable
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0<kotlin.Unit>
EXPRESSION_BODY
TYPE_OP type=java.lang.Runnable origin=SAM_CONVERSION typeOperand=java.lang.Runnable
GET_VAR 'function: kotlin.Function0<kotlin.Unit> declared in <root>.test1b.Runnable' type=kotlin.Function0<kotlin.Unit> origin=null
FUNCTION_REFERENCE 'local final fun Runnable (function: kotlin.Function0<kotlin.Unit>): java.lang.Runnable declared in <root>.test1b' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0<kotlin.Unit>, java.lang.Runnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
GET_VAR 'function: kotlin.Function0<kotlin.Unit> declared in <root>.test1b.KRunnable' type=kotlin.Function0<kotlin.Unit> origin=null
FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0<kotlin.Unit>): <root>.KRunnable declared in <root>.test1b' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0<kotlin.Unit>, <root>.KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Function1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.Function1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> declared in <root>'
@@ -24,7 +24,7 @@ fun test1() = ::KRunnable
fun test1a() = ::KR
fun test1b(): KFunction<Runnable> = ::Runnable
fun test1b(): KFunction<KRunnable> = ::KRunnable
fun test2(): (() -> String) -> KSupplier<String> = ::KSupplier
@@ -32,11 +32,11 @@ fun test1a(): KFunction1<@ParameterName(name = "function") Function0<Unit>, KRun
}
}
fun test1b(): KFunction<Runnable> {
fun test1b(): KFunction<KRunnable> {
return { // BLOCK
local fun Runnable(function: Function0<Unit>): Runnable function /*-> Runnable */
local fun KRunnable(function: Function0<Unit>): KRunnable function /*-> KRunnable */
::Runnable
::KRunnable
}
}