fix for KT-29471

#KT-29471 Fixed
This commit is contained in:
Kevin Bierhoff
2019-08-26 12:43:26 -07:00
committed by Alexey Tsvetkov
parent 220a8f2872
commit bc207ed8db
4 changed files with 36 additions and 4 deletions
@@ -0,0 +1,13 @@
package app
import lib.*
fun runAppAndReturnOk(): String {
val a = lib.getCounter { 100 }
val x = a.getInt()
if (x != 100) error("a returned $x but expected '100'")
val y = a.getInt()
if (y != 101) error("a returned $y but expected '101'")
return "OK"
}
@@ -0,0 +1,11 @@
package lib
interface Interface {
fun getInt(): Int
}
inline fun getCounter(crossinline init: () -> Int): Interface =
object : Interface {
var value = init()
override fun getInt(): Int = value++
}