Files
kotlin-fork/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt1219.1301.jet
T
2012-03-12 22:54:24 +04:00

25 lines
533 B
Plaintext

//KT-1219 Incorrect 'unused value' error in closures
package kt1219
fun <T, R> Iterable<T>.fold(var r: R, op: (T, R) -> R) : R {
this.foreach { r = op(it, r) } //unused value here
return r
}
//KT-1301 Modification of local of outer function in a local function should not be marked as unused assignment
fun foo(){
var local = 0
fun bar(){
local = 1
}
bar()
System.out?.println(local)
}
fun <T> Iterable<T>.foreach(operation: (element: T) -> Unit) {
for (elem in this)
operation(elem)
}