mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 08:31:35 +00:00
Original problem is that lowered ir closures doesn't meet inliner expectations
about captured variable position in inlining method.
E.g.: Call 'foo(valueParam) { capturedParam }' to
inline function 'foo' with declaration
inline fun foo(valueParam: Foo, inlineParamWithCaptured: Bar.() ->) ....
is reorganized through inlining to equivalent call foo(valueParam, capturedParam1, cp2 ...).
But lowered closure for lambda parameter has totally different parameters order:
fun loweredLambda$x(extensionReceiver, captured1, cp2..., valueParam1, vp2...)
So before inlining lowered closure should be transformed to
fun loweredLambda$x(extensionReceiver, valueParam1, vp2..., captured1, cp2..)
#KT-28547 Fixed
25 lines
590 B
Kotlin
Vendored
25 lines
590 B
Kotlin
Vendored
// TARGET_BACKEND: JVM
|
|
// WITH_RUNTIME
|
|
|
|
operator fun String.iterator(): IntIterator = object : IntIterator() {
|
|
private var index = 0
|
|
|
|
override fun nextInt() = codePointAt(index).apply {
|
|
index += Character.charCount(this)
|
|
}
|
|
|
|
override fun hasNext(): Boolean = index < length
|
|
}
|
|
|
|
fun String.collectInts(): List<Int> {
|
|
val result = ArrayList<Int>()
|
|
for (c in this) {
|
|
result.add(c)
|
|
}
|
|
return result
|
|
}
|
|
|
|
fun box(): String {
|
|
val ints = String(Character.toChars(127849)).collectInts()
|
|
return if (ints == listOf(127849)) "OK" else "Fail: $ints"
|
|
} |