Files
kotlin-fork/compiler/testData/diagnostics/tests/regressions/kt58.kt
T
Andrey Breslav 3d8d92c7d3 JetDiagnosticsTest migrated to TestGenerator
- test data files renamed from *.jet to *.kt
2012-07-10 14:48:11 +04:00

92 lines
1.4 KiB
Kotlin

//KT-58 Allow finally around definite returns
package kt58
import java.util.concurrent.locks.Lock
fun lock<T>(lock : Lock, body : () -> T) : T {
lock.lock()
try {
return body()
}
finally {
lock.unlock(); // we report an error, but we chouldn't
}
}
//more tests
fun t1() : Int {
try {
<!UNREACHABLE_CODE!>return 1<!>
}
finally {
return 2
}
}
fun t2() : Int {
try {
return 1
}
finally {
doSmth(3)
}
}
fun t3() : Int {
try {
return 1
}
catch (e: UnsupportedOperationException) {
doSmth(2)
}
finally {
doSmth(3)
}
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun t4() : Int {
try {
return 1
}
catch (e: UnsupportedOperationException) {
doSmth(2)
}
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun t5() : Int {
try {
return 1
}
catch (e: UnsupportedOperationException) {
return 2
}
}
fun t6() : Int {
try {
return 1
}
catch (e: UnsupportedOperationException) {
return 2
}
finally {
doSmth(3)
}
}
fun t7() : Int {
try {
doSmth(1)
}
catch (e: UnsupportedOperationException) {
return 2
}
finally {
doSmth(3)
}
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun doSmth(<!UNUSED_PARAMETER!>i<!>: Int) {
}