mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 08:31:29 +00:00
IR: Don't use IrStringConcatenation for ordinary toString calls
We can only use IrStrinConcatentation to represent calls to Any?.toString and toString calls on primitive types. Otherwise, x.toString() and "$x" are observably different when x is a non-null type with null value (e.g., an @NotNull value coming from Java).
This commit is contained in:
committed by
Dmitry Petrov
parent
c1b9fdd2f3
commit
58685be4e2
12
compiler/testData/codegen/bytecodeText/stringOperations/stringBuilderToString.kt
vendored
Normal file
12
compiler/testData/codegen/bytecodeText/stringOperations/stringBuilderToString.kt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
val chars = listOf('O', 'K')
|
||||
|
||||
fun box(): String {
|
||||
val b = StringBuilder()
|
||||
for (c in chars) {
|
||||
b.append(c)
|
||||
}
|
||||
return b.toString()
|
||||
}
|
||||
|
||||
// 0 INVOKESTATIC java/lang/String.valueOf
|
||||
// 1 INVOKEVIRTUAL java/lang/StringBuilder.toString
|
||||
Reference in New Issue
Block a user