mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
JVM_IR: fold constant string concatenations
This commit is contained in:
5
compiler/testData/codegen/bytecodeText/stringOperations/constConcat.kt
vendored
Normal file
5
compiler/testData/codegen/bytecodeText/stringOperations/constConcat.kt
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
val s = "1" + "2" + 3 + 4L + 5.0 + 6F + '7'
|
||||
val c = "${"1"}2${3}${4L}${5.0}${6F}${'7'}"
|
||||
|
||||
// 0 NEW java/lang/StringBuilder
|
||||
// 2 LDC "12345.06.07"
|
||||
12
compiler/testData/codegen/bytecodeText/stringOperations/constValConcat.kt
vendored
Normal file
12
compiler/testData/codegen/bytecodeText/stringOperations/constValConcat.kt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
const val string = "2"
|
||||
const val int = 3
|
||||
const val long = 4L
|
||||
const val double = 5.0
|
||||
const val float = 6F
|
||||
const val char = '7'
|
||||
|
||||
val s = "1" + string + int + long + double + float + char
|
||||
val c = "1$string$int$long$double$float$char"
|
||||
|
||||
// 0 NEW java/lang/StringBuilder
|
||||
// 2 LDC "12345.06.07"
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
const val empty = ""
|
||||
|
||||
val test1 = ""
|
||||
|
||||
9
compiler/testData/codegen/bytecodeText/stringOperations/partiallyConstConcat.kt
vendored
Normal file
9
compiler/testData/codegen/bytecodeText/stringOperations/partiallyConstConcat.kt
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// IGNORE_BACKEND: JVM
|
||||
fun foo(a: String, b: String) {
|
||||
val s = a + "1" + "2" + 3 + 4L + b + 5.0 + 6F + '7'
|
||||
val c = "$a${"1"}2${3}${4L}$b${5.0}${6F}${'7'}"
|
||||
}
|
||||
|
||||
// 2 NEW java/lang/StringBuilder
|
||||
// 2 LDC "1234"
|
||||
// 2 LDC "5.06.07"
|
||||
Reference in New Issue
Block a user