IR lowering for computing trimIndent/trimMargin on constants
This commit is contained in:
committed by
max-kammerer
parent
d765bebcfc
commit
aaf533df16
+11
-2
@@ -1,5 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
fun constant(): String {
|
||||
return """
|
||||
Hello,
|
||||
@@ -17,6 +15,17 @@ fun interpolatedUsingConstant(): String {
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
private const val SPACES = " "
|
||||
private const val HELLO = "Hello"
|
||||
private const val WORLD = "World"
|
||||
fun reliesOnNestedStringBuilderFlatteningAndConstantConcatenation(): String {
|
||||
return ("" + '\n' + SPACES + "${SPACES}Hey" + """
|
||||
${HELLO + HELLO},
|
||||
${WORLD + WORLD}
|
||||
""" + SPACES).trimIndent()
|
||||
}
|
||||
|
||||
// 1 LDC "Hello,\\nWorld"
|
||||
// 1 LDC "Hello,\\nHello,\\nWorld\\nWorld"
|
||||
// 1 LDC "Hey\\nHelloHello,\\nWorldWorld"
|
||||
// 0 INVOKESTATIC kotlin/text/StringsKt.trimIndent
|
||||
|
||||
+12
-2
@@ -1,5 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
fun constant(): String {
|
||||
return """
|
||||
|Hello,
|
||||
@@ -17,6 +15,17 @@ fun interpolatedUsingConstant(): String {
|
||||
""".trimMargin()
|
||||
}
|
||||
|
||||
|
||||
private const val SPACES = " "
|
||||
private const val HELLO = "Hello"
|
||||
private const val WORLD = "World"
|
||||
fun reliesOnNestedStringBuilderFlatteningAndConstantConcatenation(): String {
|
||||
return ("" + '\n' + SPACES + "${SPACES}|Hey" + """
|
||||
|${HELLO + HELLO},
|
||||
|${WORLD + WORLD}
|
||||
""" + SPACES).trimMargin()
|
||||
}
|
||||
|
||||
fun constantCustomPrefix(): String {
|
||||
return """
|
||||
###Hello,
|
||||
@@ -34,5 +43,6 @@ fun constantCustomPrefixInterpolatedUsingConstant(): String {
|
||||
|
||||
// 3 LDC "Hello,\\nWorld"
|
||||
// 1 LDC "Hello,\\nHello,\\nWorld\\nWorld"
|
||||
// 1 LDC "Hey\\nHelloHello,\\nWorldWorld"
|
||||
// 0 LDC "###"
|
||||
// 0 INVOKESTATIC kotlin/text/StringsKt.trimMargin
|
||||
|
||||
Reference in New Issue
Block a user