check definite return in local functions
This commit is contained in:
@@ -12,7 +12,7 @@ fun Array<String>.test1Nested(): Array<String> {
|
||||
fun Array<String>.test2() : Array<String> {
|
||||
class Z2() {
|
||||
fun run(): Array<String> {
|
||||
this@test2
|
||||
return this@test2
|
||||
}
|
||||
}
|
||||
return Z2().run()
|
||||
@@ -34,7 +34,7 @@ fun Array<String>.test2Nested() : Array<String> {
|
||||
|
||||
fun Array<String>.test3(): Array<String> {
|
||||
fun local(): Array<String> {
|
||||
this@test3
|
||||
return this@test3
|
||||
}
|
||||
return local()
|
||||
}
|
||||
@@ -42,7 +42,7 @@ fun Array<String>.test3(): Array<String> {
|
||||
fun Array<String>.test3Nested(): Array<String> {
|
||||
fun local(): Array<String> {
|
||||
fun local2(): Array<String> {
|
||||
this@test3Nested
|
||||
return this@test3Nested
|
||||
}
|
||||
return local2()
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ fun<TItem> Iterable<TItem>.where(predicate : (TItem)->Boolean) : Iterable<TItem>
|
||||
if (predicate(next))
|
||||
return next
|
||||
}
|
||||
null
|
||||
return null
|
||||
}
|
||||
{ yielder() }
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
trait X {
|
||||
fun f(): Boolean
|
||||
}
|
||||
|
||||
val m = object : X {
|
||||
override fun f(): Boolean {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun foo() {
|
||||
fun local(): Int {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package f
|
||||
|
||||
|
||||
//KT-3444 Front-end doesn't check if local function or function of anonymous class returns value
|
||||
|
||||
fun box(): Int {
|
||||
|
||||
fun local(): Int {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
return local()
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
box()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user