weird bug with nested closures using outer receiver

This commit is contained in:
Alex Tkachman
2012-02-20 12:14:39 +02:00
parent 046c13a264
commit 436c298e47
6 changed files with 73 additions and 10 deletions
@@ -0,0 +1,21 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.ReentrantLock;
fun <T> Int.latch(op: CountDownLatch.() -> T) : T {
val cdl = CountDownLatch(this)
val res = cdl.op()
cdl.await()
return res
}
fun id(op : ()->Unit) = op()
fun box() : String {
1.latch{
id {
countDown()
}
}
return "OK"
}