Remove obsolete code in inliner for experimental coroutines
This commit is contained in:
Vendored
-2
@@ -1,2 +0,0 @@
|
||||
warning: language version 1.2 is deprecated and its support will be removed in a future version of Kotlin
|
||||
OK
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package library
|
||||
|
||||
import kotlin.coroutines.experimental.*
|
||||
|
||||
var continuation: Continuation<Unit>? = null
|
||||
val sb = java.lang.StringBuilder()
|
||||
|
||||
fun append(s: String) { sb.append(s) }
|
||||
|
||||
val libraryResult: String get() = sb.toString()
|
||||
|
||||
// this is an inline tail-suspend function that should work properly despite being compiler by
|
||||
// compiler before 1.1.4 version that did not include suspension marks into bytecode.
|
||||
// In order to test that it works properly it shall actually suspend during its execution
|
||||
inline suspend fun foo(block: () -> Unit) {
|
||||
append("(foo)")
|
||||
block()
|
||||
return suspendCoroutine<Unit> { continuation = it }
|
||||
}
|
||||
|
||||
suspend fun bar() {
|
||||
append("(bar)")
|
||||
return suspendCoroutine<Unit> { continuation = it }
|
||||
}
|
||||
|
||||
fun resumeLibrary() {
|
||||
continuation?.let {
|
||||
continuation = null
|
||||
it.resume(Unit)
|
||||
}
|
||||
}
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
warning: language version 1.2 is deprecated and its support will be removed in a future version of Kotlin
|
||||
OK
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
import library.*
|
||||
import kotlin.coroutines.experimental.*
|
||||
|
||||
suspend fun test() {
|
||||
append("[foo]")
|
||||
foo { // we are inlining foo here
|
||||
append("(block)")
|
||||
}
|
||||
append("[bar]")
|
||||
bar() // and invoking suspending function bar
|
||||
append("[test]")
|
||||
}
|
||||
|
||||
fun runBlockingLibrary(block: suspend () -> Unit): String {
|
||||
var done = false
|
||||
block.startCoroutine(object : Continuation<Unit> {
|
||||
override val context: CoroutineContext = EmptyCoroutineContext
|
||||
override fun resume(value: Unit) { done = true }
|
||||
override fun resumeWithException(exception: Throwable) { throw exception }
|
||||
})
|
||||
var resumeCounter = 0
|
||||
while (!done) {
|
||||
resumeCounter++
|
||||
resumeLibrary()
|
||||
}
|
||||
return "$libraryResult:resumes=$resumeCounter"
|
||||
}
|
||||
|
||||
// Retruns array of expected and received string
|
||||
fun run(): Array<String> {
|
||||
val result = runBlockingLibrary {
|
||||
test()
|
||||
}
|
||||
return arrayOf("[foo](foo)(block)[bar](bar)[test]:resumes=2", result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user