IR: 'fun interface' support

This commit is contained in:
Dmitry Petrov
2020-01-20 13:36:53 +03:00
parent a55989a2a5
commit 64a405e7a0
40 changed files with 977 additions and 30 deletions
@@ -168,7 +168,8 @@ class Fir2IrDeclarationStorage(
isData = regularClass?.isData == true,
isExternal = regularClass?.isExternal == true,
isInline = regularClass?.isInline == true,
isExpect = regularClass?.isExpect == true
isExpect = regularClass?.isExpect == true,
isFun = false // TODO FirRegularClass.isFun
).apply {
descriptor.bind(this)
if (setParent && regularClass != null) {
@@ -216,7 +217,7 @@ class Fir2IrDeclarationStorage(
Name.special("<no name provided>"), anonymousObject.classKind,
Visibilities.LOCAL, modality,
isCompanion = false, isInner = false, isData = false,
isExternal = false, isInline = false, isExpect = false
isExternal = false, isInline = false, isExpect = false, isFun = false
).apply {
descriptor.bind(this)
declareThisReceiver()
@@ -236,7 +237,7 @@ class Fir2IrDeclarationStorage(
enumEntry.name, anonymousObject.classKind,
Visibilities.LOCAL, modality,
isCompanion = false, isInner = false, isData = false,
isExternal = false, isInline = false, isExpect = false
isExternal = false, isInline = false, isExpect = false, isFun = false
).apply {
descriptor.bind(this)
declareThisReceiver()
@@ -1420,6 +1420,39 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
}
}
@TestMetadata("compiler/testData/ir/irText/expressions/funInterface")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class FunInterface extends AbstractFir2IrTextTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: ");
}
public void testAllFilesPresentInFunInterface() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("basicFunInterfaceConversion.kt")
public void testBasicFunInterfaceConversion() throws Exception {
runTest("compiler/testData/ir/irText/expressions/funInterface/basicFunInterfaceConversion.kt");
}
@TestMetadata("castFromAny.kt")
public void testCastFromAny() throws Exception {
runTest("compiler/testData/ir/irText/expressions/funInterface/castFromAny.kt");
}
@TestMetadata("partialSam.kt")
public void testPartialSam() throws Exception {
runTest("compiler/testData/ir/irText/expressions/funInterface/partialSam.kt");
}
@TestMetadata("samConversionsWithSmartCasts.kt")
public void testSamConversionsWithSmartCasts() throws Exception {
runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.kt");
}
}
@TestMetadata("compiler/testData/ir/irText/expressions/sam")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -294,7 +294,8 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
isData = false,
isExternal = false,
isInline = false,
isExpect = false
isExpect = false,
isFun = false
).apply {
d.bind(this)
parent = irFunction.parent
@@ -5,10 +5,9 @@
package org.jetbrains.kotlin.ir.builders.declarations
import org.jetbrains.kotlin.backend.common.descriptors.*
import org.jetbrains.kotlin.backend.common.descriptors.synthesizedName
import org.jetbrains.kotlin.backend.common.ir.copyTo
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.*
import org.jetbrains.kotlin.ir.descriptors.*
@@ -27,7 +26,7 @@ fun IrClassBuilder.buildClass(): IrClass {
IrClassSymbolImpl(wrappedDescriptor),
name, kind, visibility, modality,
isCompanion = isCompanion, isInner = isInner, isData = isData, isExternal = isExternal,
isInline = isInline, isExpect = isExpect
isInline = isInline, isExpect = isExpect, isFun = isFun
).also {
wrappedDescriptor.bind(it)
}
@@ -127,7 +127,7 @@ class JsSharedVariablesManager(val builtIns: IrBuiltIns, val implicitDeclaration
UNDEFINED_OFFSET, UNDEFINED_OFFSET, JsLoweredDeclarationOrigin.JS_CLOSURE_BOX_CLASS_DECLARATION, IrClassSymbolImpl(descriptor),
Name.identifier(boxTypeName), ClassKind.CLASS, Visibilities.PUBLIC, Modality.FINAL,
isCompanion = false, isInner = false, isData = false, isExternal = false,
isInline = false, isExpect = false
isInline = false, isExpect = false, isFun = false
)
descriptor.bind(declaration)
@@ -58,8 +58,8 @@ class JvmGeneratorExtensions(private val generateFacades: Boolean = true) : Gene
}
override fun getSubstitutedFunctionTypeForSamType(samType: KotlinType): KotlinType {
val descriptor = samType.constructor.declarationDescriptor as? JavaClassDescriptor
?: throw AssertionError("SAM should be represented by a Java class: $samType")
val descriptor = samType.constructor.declarationDescriptor as? ClassDescriptor
?: throw AssertionError("SAM should be represented by a class: $samType")
val singleAbstractMethod = getSingleAbstractMethodOrNull(descriptor)
?: throw AssertionError("$descriptor should have a single abstract method")
val unsubstitutedFunctionType = getFunctionTypeForAbstractMethod(singleAbstractMethod, false)
@@ -236,7 +236,8 @@ class JvmDeclarationFactory(
isData = false,
isExternal = false,
isInline = false,
isExpect = false
isExpect = false,
isFun = false
).apply {
descriptor.bind(this)
parent = interfaceClass
@@ -88,7 +88,8 @@ private class FileClassLowering(val context: JvmBackendContext) : FileLoweringPa
isData = false,
isExternal = false,
isInline = false,
isExpect = false
isExpect = false,
isFun = false
).apply {
descriptor.bind(this)
superTypes.add(context.irBuiltIns.anyType)
@@ -32,5 +32,6 @@ class IrClassBuilder : IrDeclarationBuilder() {
isExternal = from.isExternal
isInline = from.isInline
isExpect = from.isExpect
isFun = from.isFun
}
}
@@ -39,6 +39,7 @@ interface IrClass :
val isExternal: Boolean
val isInline: Boolean
val isExpect: Boolean
val isFun: Boolean
val superTypes: MutableList<IrType>
@@ -44,7 +44,8 @@ class IrClassImpl(
override val isData: Boolean,
override val isExternal: Boolean,
override val isInline: Boolean,
override val isExpect: Boolean
override val isExpect: Boolean,
override val isFun: Boolean
) :
IrDeclarationBase(startOffset, endOffset, origin),
IrClass {
@@ -66,7 +67,8 @@ class IrClassImpl(
isData = symbol.descriptor.isData,
isExternal = symbol.descriptor.isEffectivelyExternal(),
isInline = symbol.descriptor.isInline,
isExpect = symbol.descriptor.isExpect
isExpect = symbol.descriptor.isExpect,
isFun = symbol.descriptor.isFun
)
init {
@@ -35,6 +35,7 @@ class IrLazyClass(
override val isExternal: Boolean,
override val isInline: Boolean,
override val isExpect: Boolean,
override val isFun: Boolean,
stubGenerator: DeclarationStubGenerator,
typeTranslator: TypeTranslator
) :
@@ -59,6 +60,7 @@ class IrLazyClass(
isExternal = symbol.descriptor.isEffectivelyExternal(),
isInline = symbol.descriptor.isInline,
isExpect = symbol.descriptor.isExpect,
isFun = symbol.descriptor.isFun,
stubGenerator = stubGenerator,
typeTranslator = TypeTranslator
)
@@ -142,12 +142,13 @@ open class DeepCopyIrTreeWithSymbols(
declaration.kind,
declaration.visibility,
declaration.modality,
declaration.isCompanion,
declaration.isInner,
declaration.isData,
declaration.isExternal,
declaration.isInline,
declaration.isExpect
isCompanion = declaration.isCompanion,
isInner = declaration.isInner,
isData = declaration.isData,
isExternal = declaration.isExternal,
isInline = declaration.isInline,
isExpect = declaration.isExpect,
isFun = declaration.isFun
).apply {
transformAnnotations(declaration)
copyTypeParametersFrom(declaration)
@@ -462,7 +462,8 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false) : IrEl
"data".takeIf { isData },
"external".takeIf { isExternal },
"inline".takeIf { isInline },
"expect".takeIf { isExpect }
"expect".takeIf { isExpect },
"fun".takeIf { isFun }
)
override fun visitVariable(declaration: IrVariable, data: Nothing?): String =
@@ -648,6 +648,7 @@ message IrClass {
required IrDeclarationContainer declaration_container = 13;
repeated int32 super_type = 14;
required bool is_expect = 15;
required bool is_fun = 16;
}
message IrTypeAlias {
@@ -980,7 +980,8 @@ abstract class IrFileDeserializer(
isData = proto.isData,
isExternal = proto.isExternal,
isInline = proto.isInline,
isExpect = proto.isExpect
isExpect = proto.isExpect,
isFun = proto.isFun
)
}.usingParent {
proto.declarationContainer.declarationList.mapTo(declarations) { deserializeDeclaration(it) }
@@ -1198,6 +1198,7 @@ open class IrFileSerializer(
.setIsExternal(clazz.isExternal)
.setIsInline(clazz.isInline)
.setIsExpect(clazz.isExpect)
.setIsFun(clazz.isFun)
.setTypeParameters(serializeIrTypeParameterContainer(clazz.typeParameters))
.setDeclarationContainer(serializeIrDeclarationContainer(clazz.declarations))
clazz.superTypes.forEach {
@@ -198,6 +198,11 @@ public final class IrClass extends
isExpect_ = input.readBool();
break;
}
case 128: {
bitField0_ |= 0x00004000;
isFun_ = input.readBool();
break;
}
}
}
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
@@ -475,6 +480,21 @@ public final class IrClass extends
return isExpect_;
}
public static final int IS_FUN_FIELD_NUMBER = 16;
private boolean isFun_;
/**
* <code>required bool is_fun = 16;</code>
*/
public boolean hasIsFun() {
return ((bitField0_ & 0x00004000) == 0x00004000);
}
/**
* <code>required bool is_fun = 16;</code>
*/
public boolean getIsFun() {
return isFun_;
}
private void initFields() {
base_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclarationBase.getDefaultInstance();
name_ = 0;
@@ -491,6 +511,7 @@ public final class IrClass extends
declarationContainer_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclarationContainer.getDefaultInstance();
superType_ = java.util.Collections.emptyList();
isExpect_ = false;
isFun_ = false;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -550,6 +571,10 @@ public final class IrClass extends
memoizedIsInitialized = 0;
return false;
}
if (!hasIsFun()) {
memoizedIsInitialized = 0;
return false;
}
if (!getBase().isInitialized()) {
memoizedIsInitialized = 0;
return false;
@@ -624,6 +649,9 @@ public final class IrClass extends
if (((bitField0_ & 0x00002000) == 0x00002000)) {
output.writeBool(15, isExpect_);
}
if (((bitField0_ & 0x00004000) == 0x00004000)) {
output.writeBool(16, isFun_);
}
output.writeRawBytes(unknownFields);
}
@@ -698,6 +726,10 @@ public final class IrClass extends
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeBoolSize(15, isExpect_);
}
if (((bitField0_ & 0x00004000) == 0x00004000)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeBoolSize(16, isFun_);
}
size += unknownFields.size();
memoizedSerializedSize = size;
return size;
@@ -822,6 +854,8 @@ public final class IrClass extends
bitField0_ = (bitField0_ & ~0x00002000);
isExpect_ = false;
bitField0_ = (bitField0_ & ~0x00004000);
isFun_ = false;
bitField0_ = (bitField0_ & ~0x00008000);
return this;
}
@@ -906,6 +940,10 @@ public final class IrClass extends
to_bitField0_ |= 0x00002000;
}
result.isExpect_ = isExpect_;
if (((from_bitField0_ & 0x00008000) == 0x00008000)) {
to_bitField0_ |= 0x00004000;
}
result.isFun_ = isFun_;
result.bitField0_ = to_bitField0_;
return result;
}
@@ -964,6 +1002,9 @@ public final class IrClass extends
if (other.hasIsExpect()) {
setIsExpect(other.getIsExpect());
}
if (other.hasIsFun()) {
setIsFun(other.getIsFun());
}
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
@@ -1022,6 +1063,10 @@ public final class IrClass extends
return false;
}
if (!hasIsFun()) {
return false;
}
if (!getBase().isInitialized()) {
return false;
@@ -1742,6 +1787,38 @@ public final class IrClass extends
return this;
}
private boolean isFun_ ;
/**
* <code>required bool is_fun = 16;</code>
*/
public boolean hasIsFun() {
return ((bitField0_ & 0x00008000) == 0x00008000);
}
/**
* <code>required bool is_fun = 16;</code>
*/
public boolean getIsFun() {
return isFun_;
}
/**
* <code>required bool is_fun = 16;</code>
*/
public Builder setIsFun(boolean value) {
bitField0_ |= 0x00008000;
isFun_ = value;
return this;
}
/**
* <code>required bool is_fun = 16;</code>
*/
public Builder clearIsFun() {
bitField0_ = (bitField0_ & ~0x00008000);
isFun_ = false;
return this;
}
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrClass)
}
@@ -153,4 +153,13 @@ public interface IrClassOrBuilder extends
* <code>required bool is_expect = 15;</code>
*/
boolean getIsExpect();
/**
* <code>required bool is_fun = 16;</code>
*/
boolean hasIsFun();
/**
* <code>required bool is_fun = 16;</code>
*/
boolean getIsFun();
}
@@ -1,7 +1,6 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JVM_IR
fun interface Foo {
fun invoke(): String
+1 -1
View File
@@ -1,7 +1,7 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JVM_IR
fun interface KRunnable {
fun invoke()
@@ -1,7 +1,6 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
fun interface MyRunnable {
@@ -1,6 +1,5 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
@@ -1,6 +1,5 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
@@ -1,6 +1,5 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
@@ -1,6 +1,5 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_COROUTINES
// WITH_RUNTIME
@@ -0,0 +1,32 @@
FILE fqName:<root> fileName:/basicFunInterfaceConversion.kt
CLASS INTERFACE name:Foo modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Foo
FUN name:invoke visibility:public modality:ABSTRACT <> ($this:<root>.Foo) returnType:kotlin.String
$this: VALUE_PARAMETER name:<this> type:<root>.Foo
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:foo visibility:public modality:FINAL <> (f:<root>.Foo) returnType:kotlin.String
VALUE_PARAMETER name:f index:0 type:<root>.Foo
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun foo (f: <root>.Foo): kotlin.String declared in <root>'
CALL 'public abstract fun invoke (): kotlin.String declared in <root>.Foo' type=kotlin.String origin=null
$this: GET_VAR 'f: <root>.Foo declared in <root>.foo' type=<root>.Foo origin=null
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test (): kotlin.String declared in <root>'
CALL 'public final fun foo (f: <root>.Foo): kotlin.String declared in <root>' type=kotlin.String origin=null
f: FUN_EXPR type=kotlin.Function0<kotlin.String> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
CONST String type=kotlin.String value="OK"
@@ -0,0 +1,9 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
fun interface Foo {
fun invoke(): String
}
fun foo(f: Foo) = f.invoke()
fun test() = foo { "OK" }
@@ -0,0 +1,34 @@
FILE fqName:<root> fileName:/basicFunInterfaceConversion.kt
CLASS INTERFACE name:Foo modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Foo
FUN name:invoke visibility:public modality:ABSTRACT <> ($this:<root>.Foo) returnType:kotlin.String
$this: VALUE_PARAMETER name:<this> type:<root>.Foo
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:foo visibility:public modality:FINAL <> (f:<root>.Foo) returnType:kotlin.String
VALUE_PARAMETER name:f index:0 type:<root>.Foo
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun foo (f: <root>.Foo): kotlin.String declared in <root>'
CALL 'public abstract fun invoke (): kotlin.String declared in <root>.Foo' type=kotlin.String origin=null
$this: GET_VAR 'f: <root>.Foo declared in <root>.foo' type=<root>.Foo origin=null
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test (): kotlin.String declared in <root>'
CALL 'public final fun foo (f: <root>.Foo): kotlin.String declared in <root>' type=kotlin.String origin=null
f: TYPE_OP type=<root>.Foo origin=SAM_CONVERSION typeOperand=<root>.Foo
FUN_EXPR type=kotlin.Function0<kotlin.String> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.String declared in <root>.test'
CONST String type=kotlin.String value="OK"
@@ -0,0 +1,26 @@
FILE fqName:<root> fileName:/castFromAny.kt
CLASS INTERFACE name:KRunnable modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.KRunnable
FUN name:invoke visibility:public modality:ABSTRACT <> ($this:<root>.KRunnable) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.KRunnable
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:test visibility:public modality:FINAL <> (a:kotlin.Any?) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Any?
BLOCK_BODY
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
GET_VAR 'a: kotlin.Any? declared in <root>.test' type=kotlin.Any? origin=null
CALL 'public abstract fun invoke (): kotlin.Unit declared in <root>.KRunnable' type=kotlin.Unit origin=null
$this: CALL 'public final fun KRunnable (block: kotlin.Function0<kotlin.Unit>): <root>.KRunnable declared in <root>' type=<root>.KRunnable origin=null
block: GET_VAR 'a: kotlin.Any? declared in <root>.test' type=kotlin.Function0<kotlin.Unit> origin=null
@@ -0,0 +1,11 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
fun interface KRunnable {
fun invoke()
}
fun test(a: Any?) {
a as () -> Unit
KRunnable(a).invoke()
}
@@ -0,0 +1,28 @@
FILE fqName:<root> fileName:/castFromAny.kt
CLASS INTERFACE name:KRunnable modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.KRunnable
FUN name:invoke visibility:public modality:ABSTRACT <> ($this:<root>.KRunnable) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.KRunnable
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:test visibility:public modality:FINAL <> (a:kotlin.Any?) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Any?
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
GET_VAR 'a: kotlin.Any? declared in <root>.test' type=kotlin.Any? origin=null
CALL 'public abstract fun invoke (): kotlin.Unit declared in <root>.KRunnable' type=kotlin.Unit origin=null
$this: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function0<kotlin.Unit>
GET_VAR 'a: kotlin.Any? declared in <root>.test' type=kotlin.Any? origin=null
@@ -0,0 +1,128 @@
FILE fqName:<root> fileName:/partialSam.kt
CLASS INTERFACE name:Fn modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Fn
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
TYPE_PARAMETER name:R index:1 variance: superTypes:[kotlin.Any?]
FUN name:run visibility:public modality:ABSTRACT <> ($this:<root>.Fn, s:kotlin.String, i:kotlin.Int, t:T of <root>.Fn) returnType:R of <root>.Fn
$this: VALUE_PARAMETER name:<this> type:<root>.Fn
VALUE_PARAMETER name:s index:0 type:kotlin.String
VALUE_PARAMETER name:i index:1 type:kotlin.Int
VALUE_PARAMETER name:t index:2 type:T of <root>.Fn
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:J modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.J
CONSTRUCTOR visibility:public <> () returnType:<root>.J [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:J modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN name:runConversion visibility:public modality:FINAL <> ($this:<root>.J, f1:<root>.Fn<kotlin.String, kotlin.Int>, f2:<root>.Fn<kotlin.Int, kotlin.String>) returnType:kotlin.Int
$this: VALUE_PARAMETER name:<this> type:<root>.J
VALUE_PARAMETER name:f1 index:0 type:<root>.Fn<kotlin.String, kotlin.Int>
VALUE_PARAMETER name:f2 index:1 type:<root>.Fn<kotlin.Int, kotlin.String>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun runConversion (f1: <root>.Fn<kotlin.String, kotlin.Int>, f2: <root>.Fn<kotlin.Int, kotlin.String>): kotlin.Int declared in <root>.J'
CALL 'public abstract fun run (s: kotlin.String, i: kotlin.Int, t: kotlin.String): kotlin.Int declared in <root>.Fn' type=kotlin.Int origin=null
$this: GET_VAR 'f1: <root>.Fn<kotlin.String, kotlin.Int> declared in <root>.J.runConversion' type=<root>.Fn<kotlin.String, kotlin.Int> origin=null
s: CONST String type=kotlin.String value="Bar"
i: CONST Int type=kotlin.Int value=1
t: CALL 'public abstract fun run (s: kotlin.String, i: kotlin.Int, t: kotlin.Int): kotlin.String declared in <root>.Fn' type=kotlin.String origin=null
$this: GET_VAR 'f2: <root>.Fn<kotlin.Int, kotlin.String> declared in <root>.J.runConversion' type=<root>.Fn<kotlin.Int, kotlin.String> origin=null
s: CONST String type=kotlin.String value="Foo"
i: CONST Int type=kotlin.Int value=42
t: CONST Int type=kotlin.Int value=239
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
PROPERTY name:fsi visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:fsi type:<uninitialized parent>.<anonymous> visibility:private [final,static]
EXPRESSION_BODY
BLOCK type=<root>.fsi.<no name provided> origin=OBJECT_LITERAL
CLASS OBJECT name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Fn<kotlin.String, kotlin.Int>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.fsi.<no name provided>
CONSTRUCTOR visibility:private <> () returnType:kotlin.Any [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Fn<kotlin.String, kotlin.Int>]'
FUN name:run visibility:public modality:FINAL <> ($this:<root>.fsi.<no name provided>, s:kotlin.String, i:kotlin.Int, t:kotlin.String) returnType:kotlin.Int
$this: VALUE_PARAMETER name:<this> type:<root>.fsi.<no name provided>
VALUE_PARAMETER name:s index:0 type:kotlin.String
VALUE_PARAMETER name:i index:1 type:kotlin.Int
VALUE_PARAMETER name:t index:2 type:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun run (s: kotlin.String, i: kotlin.Int, t: kotlin.String): kotlin.Int declared in <root>.fsi.<no name provided>'
CONST Int type=kotlin.Int value=1
CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.fsi.<no name provided>' type=<root>.fsi.<no name provided> origin=null
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-fsi> visibility:public modality:FINAL <> () returnType:<uninitialized parent>.<anonymous>
correspondingProperty: PROPERTY name:fsi visibility:public modality:FINAL [val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-fsi> (): <uninitialized parent>.<anonymous> declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:fsi type:<uninitialized parent>.<anonymous> visibility:private [final,static]' type=<uninitialized parent>.<anonymous> origin=null
PROPERTY name:fis visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:fis type:<uninitialized parent>.<anonymous> visibility:private [final,static]
EXPRESSION_BODY
BLOCK type=<root>.fis.<no name provided> origin=OBJECT_LITERAL
CLASS OBJECT name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Fn<kotlin.Int, kotlin.String>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.fis.<no name provided>
CONSTRUCTOR visibility:private <> () returnType:kotlin.Any [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Fn<kotlin.Int, kotlin.String>]'
FUN name:run visibility:public modality:FINAL <> ($this:<root>.fis.<no name provided>, s:kotlin.String, i:kotlin.Int, t:kotlin.Int) returnType:kotlin.String
$this: VALUE_PARAMETER name:<this> type:<root>.fis.<no name provided>
VALUE_PARAMETER name:s index:0 type:kotlin.String
VALUE_PARAMETER name:i index:1 type:kotlin.Int
VALUE_PARAMETER name:t index:2 type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun run (s: kotlin.String, i: kotlin.Int, t: kotlin.Int): kotlin.String declared in <root>.fis.<no name provided>'
CONST String type=kotlin.String value=""
CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.fis.<no name provided>' type=<root>.fis.<no name provided> origin=null
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-fis> visibility:public modality:FINAL <> () returnType:<uninitialized parent>.<anonymous>
correspondingProperty: PROPERTY name:fis visibility:public modality:FINAL [val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-fis> (): <uninitialized parent>.<anonymous> declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:fis type:<uninitialized parent>.<anonymous> visibility:private [final,static]' type=<uninitialized parent>.<anonymous> origin=null
FUN name:test visibility:public modality:FINAL <> (j:<root>.J) returnType:kotlin.Unit
VALUE_PARAMETER name:j index:0 type:<root>.J
BLOCK_BODY
CALL 'public final fun runConversion (f1: <root>.Fn<kotlin.String, kotlin.Int>, f2: <root>.Fn<kotlin.Int, kotlin.String>): kotlin.Int declared in <root>.J' type=kotlin.Int origin=null
$this: GET_VAR 'j: <root>.J declared in <root>.test' type=<root>.J origin=null
f1: CALL 'public final fun <get-fsi> (): <uninitialized parent>.<anonymous> declared in <root>' type=<uninitialized parent>.<anonymous> origin=null
f2: FUN_EXPR type=kotlin.Function3<kotlin.String, kotlin.Int, kotlin.Int, kotlin.String> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (s:kotlin.String, i:kotlin.Int, ti:kotlin.Int) returnType:kotlin.String
VALUE_PARAMETER name:s index:0 type:kotlin.String
VALUE_PARAMETER name:i index:1 type:kotlin.Int
VALUE_PARAMETER name:ti index:2 type:kotlin.Int
BLOCK_BODY
CONST String type=kotlin.String value=""
CALL 'public final fun runConversion (f1: <root>.Fn<kotlin.String, kotlin.Int>, f2: <root>.Fn<kotlin.Int, kotlin.String>): kotlin.Int declared in <root>.J' type=kotlin.Int origin=null
$this: GET_VAR 'j: <root>.J declared in <root>.test' type=<root>.J origin=null
f1: FUN_EXPR type=kotlin.Function3<kotlin.String, kotlin.Int, kotlin.String, kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (s:kotlin.String, i:kotlin.Int, ts:kotlin.String) returnType:kotlin.Int
VALUE_PARAMETER name:s index:0 type:kotlin.String
VALUE_PARAMETER name:i index:1 type:kotlin.Int
VALUE_PARAMETER name:ts index:2 type:kotlin.String
BLOCK_BODY
CONST Int type=kotlin.Int value=1
f2: CALL 'public final fun <get-fis> (): <uninitialized parent>.<anonymous> declared in <root>' type=<uninitialized parent>.<anonymous> origin=null
@@ -0,0 +1,28 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
fun interface Fn<T, R> {
fun run(s: String, i: Int, t: T): R
}
class J {
fun runConversion(f1: Fn<String, Int>, f2: Fn<Int, String>): Int {
return f1.run("Bar", 1, f2.run("Foo", 42, 239))
}
}
val fsi = object : Fn<String, Int> {
override fun run(s: String, i: Int, t: String): Int = 1
}
val fis = object : Fn<Int, String> {
override fun run(s: String, i: Int, t: Int): String = ""
}
fun test(j: J) {
j.runConversion(fsi) { s, i, ti -> ""}
j.runConversion({ s, i, ts -> 1 }, fis)
}
@@ -0,0 +1,164 @@
FILE fqName:<root> fileName:/partialSam.kt
CLASS INTERFACE name:Fn modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Fn<T of <root>.Fn, R of <root>.Fn>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
TYPE_PARAMETER name:R index:1 variance: superTypes:[kotlin.Any?]
FUN name:run visibility:public modality:ABSTRACT <> ($this:<root>.Fn<T of <root>.Fn, R of <root>.Fn>, s:kotlin.String, i:kotlin.Int, t:T of <root>.Fn) returnType:R of <root>.Fn
$this: VALUE_PARAMETER name:<this> type:<root>.Fn<T of <root>.Fn, R of <root>.Fn>
VALUE_PARAMETER name:s index:0 type:kotlin.String
VALUE_PARAMETER name:i index:1 type:kotlin.Int
VALUE_PARAMETER name:t index:2 type:T of <root>.Fn
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:J modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.J
CONSTRUCTOR visibility:public <> () returnType:<root>.J [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:J modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN name:runConversion visibility:public modality:FINAL <> ($this:<root>.J, f1:<root>.Fn<kotlin.String, kotlin.Int>, f2:<root>.Fn<kotlin.Int, kotlin.String>) returnType:kotlin.Int
$this: VALUE_PARAMETER name:<this> type:<root>.J
VALUE_PARAMETER name:f1 index:0 type:<root>.Fn<kotlin.String, kotlin.Int>
VALUE_PARAMETER name:f2 index:1 type:<root>.Fn<kotlin.Int, kotlin.String>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun runConversion (f1: <root>.Fn<kotlin.String, kotlin.Int>, f2: <root>.Fn<kotlin.Int, kotlin.String>): kotlin.Int declared in <root>.J'
CALL 'public abstract fun run (s: kotlin.String, i: kotlin.Int, t: T of <root>.Fn): R of <root>.Fn declared in <root>.Fn' type=kotlin.Int origin=null
$this: GET_VAR 'f1: <root>.Fn<kotlin.String, kotlin.Int> declared in <root>.J.runConversion' type=<root>.Fn<kotlin.String, kotlin.Int> origin=null
s: CONST String type=kotlin.String value="Bar"
i: CONST Int type=kotlin.Int value=1
t: CALL 'public abstract fun run (s: kotlin.String, i: kotlin.Int, t: T of <root>.Fn): R of <root>.Fn declared in <root>.Fn' type=kotlin.String origin=null
$this: GET_VAR 'f2: <root>.Fn<kotlin.Int, kotlin.String> declared in <root>.J.runConversion' type=<root>.Fn<kotlin.Int, kotlin.String> origin=null
s: CONST String type=kotlin.String value="Foo"
i: CONST Int type=kotlin.Int value=42
t: CONST Int type=kotlin.Int value=239
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
PROPERTY name:fsi visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:fsi type:<root>.Fn<kotlin.String, kotlin.Int> visibility:private [final,static]
EXPRESSION_BODY
BLOCK type=<root>.fsi.<no name provided> origin=OBJECT_LITERAL
CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Fn<kotlin.String, kotlin.Int>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.fsi.<no name provided>
CONSTRUCTOR visibility:public <> () returnType:<root>.fsi.<no name provided> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Fn<kotlin.String, kotlin.Int>]'
FUN name:run visibility:public modality:OPEN <> ($this:<root>.fsi.<no name provided>, s:kotlin.String, i:kotlin.Int, t:kotlin.String) returnType:kotlin.Int
overridden:
public abstract fun run (s: kotlin.String, i: kotlin.Int, t: T of <root>.Fn): R of <root>.Fn declared in <root>.Fn
$this: VALUE_PARAMETER name:<this> type:<root>.fsi.<no name provided>
VALUE_PARAMETER name:s index:0 type:kotlin.String
VALUE_PARAMETER name:i index:1 type:kotlin.Int
VALUE_PARAMETER name:t index:2 type:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun run (s: kotlin.String, i: kotlin.Int, t: kotlin.String): kotlin.Int declared in <root>.fsi.<no name provided>'
CONST Int type=kotlin.Int value=1
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Fn
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Fn
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in <root>.Fn
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.fsi.<no name provided>' type=<root>.fsi.<no name provided> origin=OBJECT_LITERAL
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-fsi> visibility:public modality:FINAL <> () returnType:<root>.Fn<kotlin.String, kotlin.Int>
correspondingProperty: PROPERTY name:fsi visibility:public modality:FINAL [val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-fsi> (): <root>.Fn<kotlin.String, kotlin.Int> declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:fsi type:<root>.Fn<kotlin.String, kotlin.Int> visibility:private [final,static]' type=<root>.Fn<kotlin.String, kotlin.Int> origin=null
PROPERTY name:fis visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:fis type:<root>.Fn<kotlin.Int, kotlin.String> visibility:private [final,static]
EXPRESSION_BODY
BLOCK type=<root>.fis.<no name provided> origin=OBJECT_LITERAL
CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Fn<kotlin.Int, kotlin.String>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.fis.<no name provided>
CONSTRUCTOR visibility:public <> () returnType:<root>.fis.<no name provided> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Fn<kotlin.Int, kotlin.String>]'
FUN name:run visibility:public modality:OPEN <> ($this:<root>.fis.<no name provided>, s:kotlin.String, i:kotlin.Int, t:kotlin.Int) returnType:kotlin.String
overridden:
public abstract fun run (s: kotlin.String, i: kotlin.Int, t: T of <root>.Fn): R of <root>.Fn declared in <root>.Fn
$this: VALUE_PARAMETER name:<this> type:<root>.fis.<no name provided>
VALUE_PARAMETER name:s index:0 type:kotlin.String
VALUE_PARAMETER name:i index:1 type:kotlin.Int
VALUE_PARAMETER name:t index:2 type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun run (s: kotlin.String, i: kotlin.Int, t: kotlin.Int): kotlin.String declared in <root>.fis.<no name provided>'
CONST String type=kotlin.String value=""
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Fn
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Fn
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in <root>.Fn
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.fis.<no name provided>' type=<root>.fis.<no name provided> origin=OBJECT_LITERAL
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-fis> visibility:public modality:FINAL <> () returnType:<root>.Fn<kotlin.Int, kotlin.String>
correspondingProperty: PROPERTY name:fis visibility:public modality:FINAL [val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-fis> (): <root>.Fn<kotlin.Int, kotlin.String> declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:fis type:<root>.Fn<kotlin.Int, kotlin.String> visibility:private [final,static]' type=<root>.Fn<kotlin.Int, kotlin.String> origin=null
FUN name:test visibility:public modality:FINAL <> (j:<root>.J) returnType:kotlin.Unit
VALUE_PARAMETER name:j index:0 type:<root>.J
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
CALL 'public final fun runConversion (f1: <root>.Fn<kotlin.String, kotlin.Int>, f2: <root>.Fn<kotlin.Int, kotlin.String>): kotlin.Int declared in <root>.J' type=kotlin.Int origin=null
$this: GET_VAR 'j: <root>.J declared in <root>.test' type=<root>.J origin=null
f1: CALL 'public final fun <get-fsi> (): <root>.Fn<kotlin.String, kotlin.Int> declared in <root>' type=<root>.Fn<kotlin.String, kotlin.Int> origin=GET_PROPERTY
f2: TYPE_OP type=<root>.Fn<kotlin.Int, kotlin.String> origin=SAM_CONVERSION typeOperand=<root>.Fn<kotlin.Int, kotlin.String>
FUN_EXPR type=kotlin.Function3<@[ParameterName(name = 's')] kotlin.String, @[ParameterName(name = 'i')] kotlin.Int, @[ParameterName(name = 't')] kotlin.Int, kotlin.String> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (s:kotlin.String, i:kotlin.Int, ti:kotlin.Int) returnType:kotlin.String
VALUE_PARAMETER name:s index:0 type:kotlin.String
VALUE_PARAMETER name:i index:1 type:kotlin.Int
VALUE_PARAMETER name:ti index:2 type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (s: kotlin.String, i: kotlin.Int, ti: kotlin.Int): kotlin.String declared in <root>.test'
CONST String type=kotlin.String value=""
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
CALL 'public final fun runConversion (f1: <root>.Fn<kotlin.String, kotlin.Int>, f2: <root>.Fn<kotlin.Int, kotlin.String>): kotlin.Int declared in <root>.J' type=kotlin.Int origin=null
$this: GET_VAR 'j: <root>.J declared in <root>.test' type=<root>.J origin=null
f1: TYPE_OP type=<root>.Fn<kotlin.String, kotlin.Int> origin=SAM_CONVERSION typeOperand=<root>.Fn<kotlin.String, kotlin.Int>
FUN_EXPR type=kotlin.Function3<@[ParameterName(name = 's')] kotlin.String, @[ParameterName(name = 'i')] kotlin.Int, @[ParameterName(name = 't')] kotlin.String, kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (s:kotlin.String, i:kotlin.Int, ts:kotlin.String) returnType:kotlin.Int
VALUE_PARAMETER name:s index:0 type:kotlin.String
VALUE_PARAMETER name:i index:1 type:kotlin.Int
VALUE_PARAMETER name:ts index:2 type:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (s: kotlin.String, i: kotlin.Int, ts: kotlin.String): kotlin.Int declared in <root>.test'
CONST Int type=kotlin.Int value=1
f2: CALL 'public final fun <get-fis> (): <root>.Fn<kotlin.Int, kotlin.String> declared in <root>' type=<root>.Fn<kotlin.Int, kotlin.String> origin=GET_PROPERTY
@@ -0,0 +1,113 @@
FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
CLASS INTERFACE name:KRunnable modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.KRunnable
FUN name:run visibility:public modality:ABSTRACT <> ($this:<root>.KRunnable) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.KRunnable
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:id visibility:public modality:FINAL <T> (x:T of <root>.id) returnType:T of <root>.id
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
VALUE_PARAMETER name:x index:0 type:T of <root>.id
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun id <T> (x: T of <root>.id): T of <root>.id declared in <root>'
GET_VAR 'x: T of <root>.id declared in <root>.id' type=T of <root>.id origin=null
FUN name:run1 visibility:public modality:FINAL <> (r:<root>.KRunnable) returnType:kotlin.Unit
VALUE_PARAMETER name:r index:0 type:<root>.KRunnable
BLOCK_BODY
FUN name:run2 visibility:public modality:FINAL <> (r1:<root>.KRunnable, r2:<root>.KRunnable) returnType:kotlin.Unit
VALUE_PARAMETER name:r1 index:0 type:<root>.KRunnable
VALUE_PARAMETER name:r2 index:1 type:<root>.KRunnable
BLOCK_BODY
FUN name:test0 visibility:public modality:FINAL <T> (a:T of <root>.test0) returnType:kotlin.Unit
TYPE_PARAMETER name:T index:0 variance: superTypes:[<root>.KRunnable; kotlin.Function0<kotlin.Unit>]
VALUE_PARAMETER name:a index:0 type:T of <root>.test0
BLOCK_BODY
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: GET_VAR 'a: T of <root>.test0 declared in <root>.test0' type=T of <root>.test0 origin=null
FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
then: CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=<root>.KRunnable origin=null
FUN name:test2 visibility:public modality:FINAL <> (a:<root>.KRunnable) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:<root>.KRunnable
BLOCK_BODY
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
GET_VAR 'a: <root>.KRunnable declared in <root>.test2' type=<root>.KRunnable origin=null
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: GET_VAR 'a: <root>.KRunnable declared in <root>.test2' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
then: CALL 'public final fun run2 (r1: <root>.KRunnable, r2: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r1: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=<root>.KRunnable origin=null
r2: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=<root>.KRunnable origin=null
FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>, b:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
VALUE_PARAMETER name:b index:1 type:kotlin.Function0<kotlin.Unit>
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
then: CALL 'public final fun run2 (r1: <root>.KRunnable, r2: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r1: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=<root>.KRunnable origin=null
r2: GET_VAR 'b: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Any
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Any origin=null
then: CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: GET_VAR 'a: kotlin.Any declared in <root>.test5' type=<root>.KRunnable origin=null
FUN name:test5x visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Any
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
then: BLOCK type=kotlin.Unit origin=null
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=<root>.KRunnable origin=null
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=<root>.KRunnable origin=null
FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Any
BLOCK_BODY
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
GET_VAR 'a: kotlin.Any declared in <root>.test6' type=kotlin.Any origin=null
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: GET_VAR 'a: kotlin.Any declared in <root>.test6' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test8 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
BLOCK_BODY
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: CALL 'public final fun id <T> (x: T of <root>.id): T of <root>.id declared in <root>' type=kotlin.Function0<kotlin.Unit> origin=null
<T>: kotlin.Function0<kotlin.Unit>
x: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test8' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: FUNCTION_REFERENCE 'public final fun test9 (): kotlin.Unit declared in <root>' type=kotlin.reflect.KFunction0<kotlin.Unit> origin=null
@@ -0,0 +1,83 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
fun interface KRunnable {
fun run()
}
fun <T> id(x: T) = x
fun run1(r: KRunnable) {}
fun run2(r1: KRunnable, r2: KRunnable) {}
fun <T> test0(a: T) where T : KRunnable, T : () -> Unit {
run1(a)
}
fun test1(a: () -> Unit) {
if (a is KRunnable) {
run1(a)
}
}
fun test2(a: KRunnable) {
a as () -> Unit
run1(a)
}
fun test3(a: () -> Unit) {
if (a is KRunnable) {
run2(a, a)
}
}
fun test4(a: () -> Unit, b: () -> Unit) {
if (a is KRunnable) {
run2(a, b)
}
}
fun test5(a: Any) {
if (a is KRunnable) {
run1(a)
}
}
fun test5x(a: Any) {
if (a is KRunnable) {
a as () -> Unit
run1(a)
}
}
fun test6(a: Any) {
a as () -> Unit
run1(a)
}
// TODO see KT-36013
//fun test7(a: (Int) -> Int) {
// a as () -> Unit
// run1(a)
//}
//
//fun <T : (Int) -> Int> test7a(a: T) {
// a as () -> Unit
// run1(a)
//}
//
//fun <T> test7b(a: T) where T : (Int) -> Int, T : () -> Unit {
// run1(a)
//}
//
//interface Unrelated
//
//fun <T> test7c(a: T) where T : Unrelated, T : () -> Unit {
// run1(a)
//}
fun test8(a: () -> Unit) {
run1(id(a))
}
fun test9() {
run1(::test9)
}
@@ -0,0 +1,131 @@
FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
CLASS INTERFACE name:KRunnable modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.KRunnable
FUN name:run visibility:public modality:ABSTRACT <> ($this:<root>.KRunnable) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.KRunnable
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:id visibility:public modality:FINAL <T> (x:T of <root>.id) returnType:T of <root>.id
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
VALUE_PARAMETER name:x index:0 type:T of <root>.id
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun id <T> (x: T of <root>.id): T of <root>.id declared in <root>'
GET_VAR 'x: T of <root>.id declared in <root>.id' type=T of <root>.id origin=null
FUN name:run1 visibility:public modality:FINAL <> (r:<root>.KRunnable) returnType:kotlin.Unit
VALUE_PARAMETER name:r index:0 type:<root>.KRunnable
BLOCK_BODY
FUN name:run2 visibility:public modality:FINAL <> (r1:<root>.KRunnable, r2:<root>.KRunnable) returnType:kotlin.Unit
VALUE_PARAMETER name:r1 index:0 type:<root>.KRunnable
VALUE_PARAMETER name:r2 index:1 type:<root>.KRunnable
BLOCK_BODY
FUN name:test0 visibility:public modality:FINAL <T> (a:T of <root>.test0) returnType:kotlin.Unit
TYPE_PARAMETER name:T index:0 variance: superTypes:[<root>.KRunnable; kotlin.Function0<kotlin.Unit>]
VALUE_PARAMETER name:a index:0 type:T of <root>.test0
BLOCK_BODY
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: GET_VAR 'a: T of <root>.test0 declared in <root>.test0' type=T of <root>.test0 origin=null
FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test2 visibility:public modality:FINAL <> (a:<root>.KRunnable) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:<root>.KRunnable
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
GET_VAR 'a: <root>.KRunnable declared in <root>.test2' type=<root>.KRunnable origin=null
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: GET_VAR 'a: <root>.KRunnable declared in <root>.test2' type=<root>.KRunnable origin=null
FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'public final fun run2 (r1: <root>.KRunnable, r2: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r1: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
r2: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>, b:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
VALUE_PARAMETER name:b index:1 type:kotlin.Function0<kotlin.Unit>
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'public final fun run2 (r1: <root>.KRunnable, r2: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r1: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
r2: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
GET_VAR 'b: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Any
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Any origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Any origin=null
FUN name:test5x visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Any
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
then: BLOCK type=kotlin.Unit origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Any
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
GET_VAR 'a: kotlin.Any declared in <root>.test6' type=kotlin.Any origin=null
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function0<kotlin.Unit>
GET_VAR 'a: kotlin.Any declared in <root>.test6' type=kotlin.Any origin=null
FUN name:test8 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
BLOCK_BODY
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
CALL 'public final fun id <T> (x: T of <root>.id): T of <root>.id declared in <root>' type=kotlin.Function0<kotlin.Unit> origin=null
<T>: kotlin.Function0<kotlin.Unit>
x: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test8' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
r: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
FUNCTION_REFERENCE 'public final fun test9 (): kotlin.Unit declared in <root>' type=kotlin.reflect.KFunction0<kotlin.Unit> origin=null
@@ -1419,6 +1419,39 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
}
}
@TestMetadata("compiler/testData/ir/irText/expressions/funInterface")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class FunInterface extends AbstractIrTextTestCase {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInFunInterface() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("basicFunInterfaceConversion.kt")
public void testBasicFunInterfaceConversion() throws Exception {
runTest("compiler/testData/ir/irText/expressions/funInterface/basicFunInterfaceConversion.kt");
}
@TestMetadata("castFromAny.kt")
public void testCastFromAny() throws Exception {
runTest("compiler/testData/ir/irText/expressions/funInterface/castFromAny.kt");
}
@TestMetadata("partialSam.kt")
public void testPartialSam() throws Exception {
runTest("compiler/testData/ir/irText/expressions/funInterface/partialSam.kt");
}
@TestMetadata("samConversionsWithSmartCasts.kt")
public void testSamConversionsWithSmartCasts() throws Exception {
runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.kt");
}
}
@TestMetadata("compiler/testData/ir/irText/expressions/sam")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -22,7 +22,7 @@ fun String.parseKonanAbiVersion(): KotlinAbiVersion {
data class KotlinAbiVersion(val version: Int) {
companion object {
val CURRENT = KotlinAbiVersion(23)
val CURRENT = KotlinAbiVersion(24)
}
override fun toString() = "$version"