Add intrinsics for compile-time computing trimMargin/trimIndent
These only apply when the receiver can be resolved to a constant and the margin prefix, if specified, is also a constant.
This commit is contained in:
committed by
Alexander Udalov
parent
2ec6ab92b5
commit
6ee987fa2e
@@ -0,0 +1,22 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
fun constant(): String {
|
||||
return """
|
||||
Hello,
|
||||
World
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
private const val HAS_INDENT = """Hello,
|
||||
World"""
|
||||
fun interpolatedUsingConstant(): String {
|
||||
return """
|
||||
Hello,
|
||||
$HAS_INDENT
|
||||
World
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
// 1 LDC "Hello,\\nWorld"
|
||||
// 1 LDC "Hello,\\nHello,\\nWorld\\nWorld"
|
||||
// 0 INVOKESTATIC kotlin/text/StringsKt.trimIndent
|
||||
Reference in New Issue
Block a user