@CompileTimeCalculation fun sum(a: Int = 1, b: Int = 2, c: Int = 3) = a + b + c @CompileTimeCalculation fun sumBasedOnPrevious(a: Int = 1, b: Int = a * 2, c: Int = b * 2, d: Int = b * 2) = a + b + c + d @CompileTimeCalculation interface A { fun foo(x: Int, y: Int = x + 20, z: Int = y * 2) = z } @CompileTimeCalculation class B : A {} const val sum1 = sum() const val sum2 = sum(b = -3) const val sum3 = sum(c = 1, a = 1, b = 1) const val sumBasedOnPrevious1 = sumBasedOnPrevious() const val sumBasedOnPrevious2 = sumBasedOnPrevious(b = 1, c = 1) const val sumBasedOnPrevious3 = sumBasedOnPrevious(a = 1, c = 1) const val sumInInterfaceDefault1 = B().foo(1) const val sumInInterfaceDefault2 = B().foo(x = 1, y = 2) const val sumInInterfaceDefault3 = B().foo(x = 1, y = 2, z = -1) const val someConstProp = 0 @CompileTimeCalculation class Outer { val prop = -1 inner class Inner { val innerProp = -2 fun withInner(x: Int = prop) = x fun withOuter(x: Int = innerProp) = x fun withGlobal(x: Int = someConstProp) = x } } const val inner1 = Outer().Inner().withInner(100) const val inner2 = Outer().Inner().withInner() const val inner3 = Outer().Inner().withOuter(100) const val inner4 = Outer().Inner().withOuter() const val inner5 = Outer().Inner().withGlobal(100) const val inner6 = Outer().Inner().withGlobal() @CompileTimeCalculation interface I { val prop: T fun foo(x: T = prop): T } open class C { open fun foo(x: T) = x } @CompileTimeCalculation class D(override val prop: Int): C(), I {} const val fooB1 = D(10).foo() const val fooB2 = D(10).foo(-1)