blob: 3a7643cd6571271e37b381433b706868a0d560ad [file]
// IGNORE_BACKEND: JVM_IR, JVM_IR_SERIALIZE
// ^^^ CIRCULAR REFERENCE: java.lang.AssertionError: D8 dexing warning: Ignoring an implementation of the method `int foo.Counter.getCount()` because it has multiple definitions
// FILE: lib.kt
package foo
import kotlin.test.*
class Runner {
public fun run(f: () -> Unit): Unit = f()
}
class Counter() {
var count = 0
val runner = Runner()
public fun count(n: Int) {
for (i in 1..n) {
tick()
}
}
public fun getCount(): Int = count
private inline fun tick() {
runner.run { count++ }
}
}
// FILE: main.kt
package foo
import kotlin.test.*
fun add(a: Int, b: Int): Int {
val counter = Counter()
counter.count(a)
counter.count(b)
return counter.getCount()
}
fun box(): String {
assertEquals(3, add(1, 2))
assertEquals(7, add(3, 4))
return "OK"
}