Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/kt27113.kt
T
Dmitry Petrov 70e60ea9bc Fix inline class coercion in string template with StringBuilder.append
Inline class values with array as a carrier type were not boxed.

 #KT-27113
2018-10-03 11:09:41 +03:00

19 lines
586 B
Kotlin
Vendored

// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JS, JS_IR, JVM_IR
// WITH_RUNTIME
class CharacterLiteral(private val prefix: NamelessString, private val s: NamelessString) {
override fun toString(): String = "$prefix'$s'"
}
inline class NamelessString(val b: ByteArray) {
override fun toString(): String = String(b)
}
fun box(): String {
val ns1 = NamelessString("abc".toByteArray())
val ns2 = NamelessString("def".toByteArray())
val cl = CharacterLiteral(ns1, ns2)
if (cl.toString() != "abc'def'") return throw AssertionError(cl.toString())
return "OK"
}