Support SAM conversion in psi2ir

SAM conversion takes a function value (function type or a subtype),
and produces a SAM interface value.
This commit is contained in:
Dmitry Petrov
2018-12-17 17:00:58 +03:00
parent 2c327564d5
commit 85f55dec9a
15 changed files with 494 additions and 19 deletions
@@ -0,0 +1,7 @@
// WITH_JDK
fun test1() = Runnable { }
fun test2(a: () -> Unit) = Runnable(a)
fun foo() {}
fun test3() = Runnable(::foo)
@@ -0,0 +1,27 @@
FILE fqName:<root> fileName:/samConstructors.kt
FUN name:test1 visibility:public modality:FINAL <> () returnType:java.lang.Runnable flags:
BLOCK_BODY
RETURN type=kotlin.Nothing from='test1(): Runnable'
TYPE_OP type=java.lang.Runnable origin=SAM_CONVERSION typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
BLOCK type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit flags:
BLOCK_BODY
RETURN type=kotlin.Nothing from='<anonymous>(): Unit'
GET_OBJECT 'Unit' type=kotlin.Unit
FUNCTION_REFERENCE '<anonymous>(): Unit' type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:java.lang.Runnable flags:
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit> flags:
BLOCK_BODY
RETURN type=kotlin.Nothing from='test2(() -> Unit): Runnable'
TYPE_OP type=java.lang.Runnable origin=SAM_CONVERSION typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit flags:
BLOCK_BODY
FUN name:test3 visibility:public modality:FINAL <> () returnType:java.lang.Runnable flags:
BLOCK_BODY
RETURN type=kotlin.Nothing from='test3(): Runnable'
TYPE_OP type=java.lang.Runnable origin=SAM_CONVERSION typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
FUNCTION_REFERENCE 'foo(): Unit' type=kotlin.reflect.KFunction0<kotlin.Unit> origin=null
@@ -0,0 +1,31 @@
// WITH_JDK
// FILE: samConversions.kt
fun J.test0(a: Runnable) {
J.runStatic(a)
runIt(a)
}
fun test1() {
J.runStatic { test1() }
}
fun J.test2() {
runIt { test1() }
}
fun J.test3(a: () -> Unit) {
run2(a, a)
}
fun J.test4(a: () -> Unit, b: () -> Unit, flag: Boolean) {
runIt(if (flag) a else b)
}
// FILE: J.java
public class J {
public static void runStatic(Runnable r) {}
public void runIt(Runnable r) {}
public void run2(Runnable r1, Runnable r2) {}
}
@@ -0,0 +1,63 @@
FILE fqName:<root> fileName:/samConversions.kt
FUN name:test0 visibility:public modality:FINAL <> ($receiver:J, a:java.lang.Runnable) returnType:kotlin.Unit flags:
$receiver: VALUE_PARAMETER name:<this> type:J flags:
VALUE_PARAMETER name:a index:0 type:java.lang.Runnable flags:
BLOCK_BODY
CALL 'runStatic(Runnable!): Unit' type=kotlin.Unit origin=null
r: GET_VAR 'value-parameter a: Runnable' type=java.lang.Runnable origin=null
CALL 'runIt(Runnable!): Unit' type=kotlin.Unit origin=null
$this: GET_VAR 'this@test0: J' type=J origin=null
r: GET_VAR 'value-parameter a: Runnable' type=java.lang.Runnable origin=null
FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit flags:
BLOCK_BODY
CALL 'runStatic(Runnable!): Unit' type=kotlin.Unit origin=null
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
BLOCK type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit flags:
BLOCK_BODY
RETURN type=kotlin.Nothing from='<anonymous>(): Unit'
CALL 'test1(): Unit' type=kotlin.Unit origin=null
FUNCTION_REFERENCE '<anonymous>(): Unit' type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
FUN name:test2 visibility:public modality:FINAL <> ($receiver:J) returnType:kotlin.Unit flags:
$receiver: VALUE_PARAMETER name:<this> type:J flags:
BLOCK_BODY
CALL 'runIt(Runnable!): Unit' type=kotlin.Unit origin=null
$this: GET_VAR 'this@test2: J' type=J origin=null
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
BLOCK type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit flags:
BLOCK_BODY
RETURN type=kotlin.Nothing from='<anonymous>(): Unit'
CALL 'test1(): Unit' type=kotlin.Unit origin=null
FUNCTION_REFERENCE '<anonymous>(): Unit' type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
FUN name:test3 visibility:public modality:FINAL <> ($receiver:J, a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit flags:
$receiver: VALUE_PARAMETER name:<this> type:J flags:
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit> flags:
BLOCK_BODY
CALL 'run2(Runnable!, Runnable!): Unit' type=kotlin.Unit origin=null
$this: GET_VAR 'this@test3: J' type=J origin=null
r1: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
r2: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test4 visibility:public modality:FINAL <> ($receiver:J, a:kotlin.Function0<kotlin.Unit>, b:kotlin.Function0<kotlin.Unit>, flag:kotlin.Boolean) returnType:kotlin.Unit flags:
$receiver: VALUE_PARAMETER name:<this> type:J flags:
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit> flags:
VALUE_PARAMETER name:b index:1 type:kotlin.Function0<kotlin.Unit> flags:
VALUE_PARAMETER name:flag index:2 type:kotlin.Boolean flags:
BLOCK_BODY
CALL 'runIt(Runnable!): Unit' type=kotlin.Unit origin=null
$this: GET_VAR 'this@test4: J' type=J origin=null
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
WHEN type=kotlin.Function0<kotlin.Unit> origin=null
BRANCH
if: GET_VAR 'value-parameter flag: Boolean' type=kotlin.Boolean origin=null
then: GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'value-parameter b: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
@@ -0,0 +1,71 @@
// !LANGUAGE: -NewInference
// NB new inference doesn't really work with old JVM back-end.
// WITH_JDK
// FILE: samConversionsWithSmartCasts.kt
fun test1(a: () -> Unit) {
if (a is Runnable) {
J.runStatic(a)
}
}
fun test2(a: () -> Unit) {
if (a is Runnable) {
J().run1(a)
}
}
fun test3(a: () -> Unit) {
if (a is Runnable) {
J().run2(a, a)
}
}
fun test4(a: () -> Unit, b: () -> Unit) {
if (a is Runnable) {
J().run2(a, b)
}
}
fun test5(a: Any) {
if (a is Runnable) {
J().run1(a)
}
}
fun test5x(a: Any) {
if (a is Runnable) {
a as () -> Unit
J().run1(a)
}
}
fun test6(a: Any) {
a as () -> Unit
J().run1(a)
}
fun test7(a: (Int) -> Int) {
a as () -> Unit
J().run1(a)
}
fun test8(a: () -> Unit) {
J().run1(J.id(a))
}
fun test9() {
J().run1(::test9)
}
// FILE: J.java
public class J {
public static void runStatic(Runnable r) {}
public void run1(Runnable r) {}
public void run2(Runnable r1, Runnable r2) {}
public static <T> T id(T x) { return x; }
}
@@ -0,0 +1,143 @@
FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit flags:
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit> flags:
BLOCK_BODY
WHEN type=kotlin.Unit origin=null
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'runStatic(Runnable!): Unit' type=kotlin.Unit origin=null
r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit flags:
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit> flags:
BLOCK_BODY
WHEN type=kotlin.Unit origin=null
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'run1(Runnable!): Unit' type=kotlin.Unit origin=null
$this: CALL 'constructor J()' type=J origin=null
r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit flags:
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit> flags:
BLOCK_BODY
WHEN type=kotlin.Unit origin=null
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'run2(Runnable!, Runnable!): Unit' type=kotlin.Unit origin=null
$this: CALL 'constructor J()' type=J origin=null
r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
r2: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: () -> Unit' 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 flags:
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit> flags:
VALUE_PARAMETER name:b index:1 type:kotlin.Function0<kotlin.Unit> flags:
BLOCK_BODY
WHEN type=kotlin.Unit origin=null
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'run2(Runnable!, Runnable!): Unit' type=kotlin.Unit origin=null
$this: CALL 'constructor J()' type=J origin=null
r1: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
r2: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter b: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit flags:
VALUE_PARAMETER name:a index:0 type:kotlin.Any flags:
BLOCK_BODY
WHEN type=kotlin.Unit origin=null
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'run1(Runnable!): Unit' type=kotlin.Unit origin=null
$this: CALL 'constructor J()' type=J origin=null
r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null
FUN name:test5x visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit flags:
VALUE_PARAMETER name:a index:0 type:kotlin.Any flags:
BLOCK_BODY
WHEN type=kotlin.Unit origin=null
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: Any' 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
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any]
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Function0 modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Function<R>]
GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null
CALL 'run1(Runnable!): Unit' type=kotlin.Unit origin=null
$this: CALL 'constructor J()' type=J origin=null
r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null
FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit flags:
VALUE_PARAMETER name:a index:0 type:kotlin.Any flags:
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any]
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Function0 modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Function<R>]
GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null
CALL 'run1(Runnable!): Unit' type=kotlin.Unit origin=null
$this: CALL 'constructor J()' type=J origin=null
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function0<kotlin.Unit>
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Function0 modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Function<R>]
GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null
FUN name:test7 visibility:public modality:FINAL <> (a:kotlin.Function1<kotlin.Int, kotlin.Int>) returnType:kotlin.Unit flags:
VALUE_PARAMETER name:a index:0 type:kotlin.Function1<kotlin.Int, kotlin.Int> flags:
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any]
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Function0 modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Function<R>]
GET_VAR 'value-parameter a: (Int) -> Int' type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=null
CALL 'run1(Runnable!): Unit' type=kotlin.Unit origin=null
$this: CALL 'constructor J()' type=J origin=null
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function0<kotlin.Unit>
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Function0 modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Function<R>]
GET_VAR 'value-parameter a: (Int) -> Int' type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=null
FUN name:test8 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit flags:
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit> flags:
BLOCK_BODY
CALL 'run1(Runnable!): Unit' type=kotlin.Unit origin=null
$this: CALL 'constructor J()' type=J origin=null
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
CALL 'id(T!): T!' type=kotlin.Function0<kotlin.Unit>? origin=null
<T : Any!>: kotlin.Function0<kotlin.Unit>?
x: GET_VAR 'value-parameter a: () -> Unit' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit flags:
BLOCK_BODY
CALL 'run1(Runnable!): Unit' type=kotlin.Unit origin=null
$this: CALL 'constructor J()' type=J origin=null
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
FUNCTION_REFERENCE 'test9(): Unit' type=kotlin.reflect.KFunction0<kotlin.Unit> origin=null
+3 -2
View File
@@ -2,8 +2,9 @@ FILE fqName:<root> fileName:/samAdapter.kt
FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit flags:
BLOCK_BODY
VAR name:hello type:java.lang.Runnable flags:val
CALL 'Runnable(() -> Unit): Runnable' type=java.lang.Runnable origin=null
function: BLOCK type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
TYPE_OP type=java.lang.Runnable origin=SAM_CONVERSION typeOperand=java.lang.Runnable
typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Runnable modality:ABSTRACT visibility:public flags: superTypes:[kotlin.Any]
BLOCK type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit flags:
BLOCK_BODY
RETURN type=kotlin.Nothing from='<anonymous>(): Unit'