Files
kotlin-fork/compiler/testData/codegen/box/constants/kt9532.kt
T
Dmitry Petrov a84c2a6f31 Improve string concatentation & string templates code generation
Reuse StringBuilder instances for nested subexpressions.
(NB StringBuilder instance for string template with a string
concatenation inside an expression entry, such as `"${"a" + "b"}"`,
will not be reused, although that doesn't seem to be a real-life issue).

 #KT-18558 Fixed Target versions 1.1.4
 #KT-13682 Fixed Target versions 1.1.4

Join adjacent strings literals, escaped strings, and constant values
(in a language version that supports const val inlining).
Use StringBuilder#append(char) for single-character constants
(e.g., " " in "$a $b").

 #KT-17280 Fixed Target versions 1.1.4
 #KT-15235 Fixed Target versions 1.1.4
2017-06-27 14:28:42 +03:00

32 lines
755 B
Kotlin
Vendored

// TODO: muted automatically, investigate should it be ran for JS or not
object A {
const val a: String = "$"
const val b = "1234$a"
const val c = 10000
val bNonConst = "1234$a"
val bNullable: String? = "1234$a"
}
object B {
const val a: String = "$"
const val b = "1234$a"
const val c = 10000
val bNonConst = "1234$a"
val bNullable: String? = "1234$a"
}
fun box(): String {
if (A.a !== B.a) return "Fail 1: A.a !== B.a"
if (A.b !== B.b) return "Fail 2: A.b !== B.b"
if (A.c !== B.c) return "Fail 3: A.c !== B.c"
if (A.bNonConst !== B.bNonConst) return "Fail 4: A.bNonConst !== B.bNonConst"
if (A.bNullable !== B.bNullable) return "Fail 5: A.bNullable !== B.bNullable"
return "OK"
}