Files
kotlin-fork/compiler/testData/codegen/box/callableReference/varargAndDefaults/manyDefaultsAndVararg.kt
T
Mikhail Zarechenskiy 04e57f712e [NI] Introduce feature for passing function references with defaults
Relates to KT-8834, we continue reducing differences between old and new
 inference. Note that as for `SamConversionPerArgument`, this feature
 is enabled in the compiler and not in the IDE to avoid breaking code
 for those users that already enabled new inference in the compiler
2019-08-07 15:58:36 +03:00

29 lines
536 B
Kotlin
Vendored

// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType
// IGNORE_BACKEND: JS
// WITH_RUNTIME
import kotlin.test.assertEquals
object E : Exception()
fun foo(
a: String = "fail",
b: Int,
c: Double = 3.14,
vararg d: String,
e: Throwable = E
) {
assertEquals("ok", a)
assertEquals(42, b)
assertEquals(3.14, c)
assertEquals(0, d.size)
assertEquals(E, e)
}
fun bar(f: (String, Int) -> Unit) = f("ok", 42)
fun box(): String {
bar(::foo)
return "OK"
}