Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/simpleSecondaryConstructor.kt
T
Vladimir Sukharev a036e41809 [Test] Convert IGNORE: NATIVE directives in box tests from D to I
^KT-59057

Merge-request: KT-MR-10748
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-23 09:11:17 +00:00

21 lines
528 B
Kotlin
Vendored

// JVM runtime exception: java.lang.ClassCastException: kotlin.Unit cannot be cast to Foo
// IGNORE_BACKEND: JVM
// 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) throw IllegalArgumentException()
if (y == 1) return
return Unit
}
constructor(z: Double) : this(z.toInt())
}
fun box(): String {
return Foo(42.0).x
}