From 26ee99185c557ef6fa7705221e2cad3e90d49044 Mon Sep 17 00:00:00 2001 From: Vasily Levchenko Date: Mon, 9 Jan 2017 18:26:24 +0300 Subject: [PATCH] IR: default parameter extension support for code ``` fun Int.foo(a:Int, b:Int = a + 1, c:Int = a + b) = a + b +c fun main(arg:Array) { 42.foo(0) } ``` we generate IR representation corresponding to the following code ``` fun Int.foo(a:Int, b:Int, c:Int) = a + b +c fun foo_default(a:Int, b:Int, c:Int, __mask__:Int, __receiver__:Int):Int { var tmpb:Int = 0 if ((__mask__ and (1 shl 1)) != 0) tmpb = a + 1 else tmpb = b var tmpc:Int = 0 if ((__mask__ and (1 shl 2)) != 0) tmpc = a + tmpb else tmpc = c return __receiver__.foo(a, tmpb, tmpc) } fun main(arg:Array) { foo_default(0, 0, 0, 6 /* (1 shl 1) | (1 shl 2)*/, 42) } ``` NOTE: if call provides all arguents we don't emit call of _default function. --- .../src/org/jetbrains/kotlin/backend/konan/KonanLower.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLower.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLower.kt index e714e9ed2de..053b74b45f5 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLower.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLower.kt @@ -51,7 +51,7 @@ internal class KonanLower(val context: Context) { Autoboxing(context).lower(irFile) } phaser.phase(KonanPhase.LOWER_INLINE) { - //FunctionInlining(context).inline(irFile) + FunctionInlining(context).inline(irFile) } } }