Files
kotlin-fork/compiler/testData/codegen/box/specialBuiltins/collectionImpl.kt
T
Mikhail Glukhikh e7e80be34a [FIR2IR] Populate overridden symbols even for !isOverride
Before this commit we considered !isOverride as a sign that
function / field / accessor has no overridden symbols.
However, it's false for deserialized, because isOverride
is always false there.

This commit fixes 68 BB tests but breaks 25 BB tests (not yet muted)
2020-05-14 13:40:36 +03:00

97 lines
2.1 KiB
Kotlin
Vendored

// TARGET_BACKEND: JVM
class A1 : MutableCollection<String> {
override val size: Int
get() = 56
override fun isEmpty(): Boolean {
throw UnsupportedOperationException()
}
override fun contains(o: String): Boolean {
throw UnsupportedOperationException()
}
override fun iterator(): MutableIterator<String> {
throw UnsupportedOperationException()
}
override fun containsAll(c: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun add(e: String): Boolean {
throw UnsupportedOperationException()
}
override fun remove(o: String): Boolean {
throw UnsupportedOperationException()
}
override fun addAll(c: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun removeAll(c: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun retainAll(c: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun clear() {
throw UnsupportedOperationException()
}
}
class A2 : java.util.AbstractCollection<String>() {
override val size: Int
get() = 56
override fun iterator(): MutableIterator<String> {
throw UnsupportedOperationException()
}
}
class A3 : java.util.ArrayList<String>() {
override val size: Int
get() = 56
}
interface Sized {
val size: Int
}
class A4 : java.util.ArrayList<String>(), Sized {
override val size: Int
get() = 56
}
fun check56(x: Collection<String>) {
if (x.size != 56) throw java.lang.RuntimeException("fail ${x.size}")
}
fun box(): String {
val a1 = A1()
if (a1.size != 56) return "fail 1: ${a1.size}"
check56(a1)
val a2 = A2()
if (a2.size != 56) return "fail 2: ${a2.size}"
check56(a2)
val a3 = A3()
if (a3.size != 56) return "fail 3: ${a3.size}"
check56(a3)
val a4 = A4()
if (a4.size != 56) return "fail 4: ${a4.size}"
check56(a4)
val sized: Sized = a4
if (sized.size != 56) return "fail 5: ${a4.size}"
return "OK"
}