Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/simpleSecondaryConstructor.kt
T
Evgeniy.Zhelenskiy 6107caa8e2 [FE1.0, FIR] Support secondary constructors for Value Classes
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:35 +00:00

23 lines
562 B
Kotlin
Vendored

// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: IGNORED_IN_JS
// IGNORE_BACKEND: JS, JS_IR, NATIVE, JVM
// IGNORE_BACKEND: JS_IR_ES6
// WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses, +ValueClassesSecondaryConstructorWithBody
OPTIONAL_JVM_INLINE_ANNOTATION
value class Foo(val x: String) {
constructor(y: Int) : this("OK") {
if (y == 0) return throw java.lang.IllegalArgumentException()
if (y == 1) return
return Unit
}
constructor(z: Double) : this(z.toInt())
}
fun box(): String {
return Foo(42.0).x
}