Files
kotlin-fork/compiler/testData/ir/irText/expressions/extFunSafeInvoke.txt
T
Dmitry Petrov 1eb693b8ee Transform variable-as-function calls for extension functions
In the following code example
  fun test(f: Any.() -> Unit) = 42.f()
front-end resolves variable-as-function call for 'f' as 'invoke'
with signature 'Function1<Any, Unit>#Any.() -> Unit'.
However, Function1<Any, Unit> has a single 'invoke' method
with signature 'Function1<Any, Unit>#(Any) -> Unit'.
This didn't cause any problems with loosely typed JVM and JS back-ends.
However, in IR with symbols this means a reference to non-existing
declaration.
2017-05-04 09:33:03 +03:00

23 lines
1.5 KiB
Plaintext
Vendored

FILE /extFunSafeInvoke.kt
FUN public fun test(receiver: kotlin.Any?, fn: kotlin.Any.(kotlin.Int, kotlin.String) -> kotlin.Unit): kotlin.Unit?
VALUE_PARAMETER value-parameter receiver: kotlin.Any?
VALUE_PARAMETER value-parameter fn: kotlin.Any.(kotlin.Int, kotlin.String) -> kotlin.Unit
BLOCK_BODY
RETURN type=kotlin.Nothing from='test(Any?, Any.(Int, String) -> Unit): Unit?'
BLOCK type=kotlin.Unit? origin=SAFE_CALL
VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: kotlin.Any?
GET_VAR 'value-parameter receiver: Any?' type=kotlin.Any? origin=null
WHEN type=kotlin.Unit? origin=SAFE_CALL
BRANCH
if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'tmp0_safe_receiver: Any?' type=kotlin.Any? origin=null
arg1: CONST Null type=kotlin.Nothing? value='null'
then: CONST Null type=kotlin.Nothing? value='null'
BRANCH
if: CONST Boolean type=kotlin.Boolean value='true'
then: CALL 'invoke(Any, Int, String): Unit' type=kotlin.Unit origin=INVOKE
$this: GET_VAR 'value-parameter fn: Any.(Int, String) -> Unit' type=kotlin.Any.(kotlin.Int, kotlin.String) -> kotlin.Unit origin=VARIABLE_AS_FUNCTION
p1: GET_VAR 'tmp0_safe_receiver: Any?' type=kotlin.Any? origin=null
p2: CONST Int type=kotlin.Int value='42'
p3: CONST String type=kotlin.String value='Hello'