Simplify generated code for rangeTo/concat intrinsics

The main reason is avoiding complicated operations like
dup + dup_x2 + pop2 for instances obtained by NEW instruction.

Otherwise it leads to problems in performRefinedTypeAnalysis
because code there has a sensible assumption that NEW instances
can be only dupped or stored into a local (rare cases)

 #KT-17457 Fixed
This commit is contained in:
Denis Zharkov
2017-05-19 16:16:08 +03:00
parent 419f12f1b7
commit 52b2e632df
12 changed files with 134 additions and 25 deletions
@@ -0,0 +1,31 @@
// WITH_RUNTIME
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.*
suspend fun getLong(): Long = suspendCoroutineOrReturn { x ->
x.resume(1234567890123L)
COROUTINE_SUSPENDED
}
suspend fun suspendHere(r: LongRange): Long = suspendCoroutineOrReturn { x ->
x.resume(r.start + r.endInclusive)
COROUTINE_SUSPENDED
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
fun box(): String {
var result = 0L
builder {
result = suspendHere(1L..getLong())
}
if (result != 1234567890124L) return "fail 1: $result"
return "OK"
}
@@ -0,0 +1,26 @@
// WITH_RUNTIME
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.*
suspend fun suspendHere(r: LongRange): Long = suspendCoroutineOrReturn { x ->
x.resume(r.start + r.endInclusive)
COROUTINE_SUSPENDED
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
fun box(): String {
var result = 0L
builder {
result = suspendHere(1L..1234567890123L)
}
if (result != 1234567890124L) return "fail 1: $result"
return "OK"
}