Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolveWithStdlib/hashTableWithForEach.kt
T
Ilya Kirillov 1bbcae5ed2 [FIR] fix resolve contract violation from scopes
We cannot call lazy resolve to STATUS phase from scopes as scopes may be accessed on a STATUS phase or earlier

^KT-54890
^KTIJ-23587 fixed
2023-01-13 21:32:51 +00:00

25 lines
858 B
Kotlin
Vendored

// FULL_JDK
import java.util.*
import java.util.function.BiConsumer
private val DEBUG = true
abstract class SomeHashTable<K : Any, V : Any> : AbstractMutableMap<K, V>() {
override fun forEach(action: BiConsumer<in K, in V>) {}
override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
get() {
if (DEBUG) {
return Collections.unmodifiableSet(
mutableSetOf<MutableMap.MutableEntry<K, V>>().apply {
forEach { key, value -> add(Entry(key, value)) }
}
)
}
throw UnsupportedOperationException()
}
private class Entry<K, V>(override val key: K, override val value: V) : MutableMap.MutableEntry<K, V> {
override fun setValue(newValue: V): V = throw UnsupportedOperationException()
}
}