Enabled disabled non-local returns in stdlib

This commit is contained in:
Michael Bogdanov
2014-10-22 12:41:45 +04:00
parent 11fd8fe392
commit 25d7c9f20a
11 changed files with 578 additions and 76 deletions
@@ -1,42 +0,0 @@
import java.io.Closeable
import java.util.concurrent.locks.Lock
import java.util.concurrent.locks.ReentrantReadWriteLock
import kotlin.concurrent.*
// Non-local returns for these functions are temporarily disabled because they contain try-finally blocks and
// the compiler doesn't correctly include the "finally" section into the inlined result.
// Once the compiler is fixed (KT-5506), non-local returns can be re-allowed for these functions
fun testSynchronized(): Int {
synchronized("") {
<!RETURN_NOT_ALLOWED!>return 1<!>
}
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun testUse(f: Closeable): Int {
f.use {
<!RETURN_NOT_ALLOWED!>return 2<!>
}
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun testWithLock(l: Lock): Int {
l.withLock {
<!RETURN_NOT_ALLOWED!>return 3<!>
}
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun testRead(l: ReentrantReadWriteLock): Int {
l.read {
<!RETURN_NOT_ALLOWED!>return 4<!>
}
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun testWrite(l: ReentrantReadWriteLock): Int {
l.write {
<!RETURN_NOT_ALLOWED!>return 5<!>
}
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
@@ -1,7 +0,0 @@
package
internal fun testRead(/*0*/ l: java.util.concurrent.locks.ReentrantReadWriteLock): kotlin.Int
internal fun testSynchronized(): kotlin.Int
internal fun testUse(/*0*/ f: java.io.Closeable): kotlin.Int
internal fun testWithLock(/*0*/ l: java.util.concurrent.locks.Lock): kotlin.Int
internal fun testWrite(/*0*/ l: java.util.concurrent.locks.ReentrantReadWriteLock): kotlin.Int