Files
kotlin-fork/compiler/testData/codegen/box/collections/addCollectionStubWithCovariantOverride.kt
T
Denis.Zharkov a750d9466e FIR2IR: Rework resulted overridden-relation structure
The difference is how we deal with intermediate fake overrides
E.g., in case

interface A { /* $1 */ fun foo() }
interface B : A {
     /* $2 */ fake_override fun foo()
}
interface C : B {
   /* $3 */ override fun foo()
}

We've got FIR declarations only for $1 and $3, but we've got
a fake override for $2 in IR.

Previously, override $3 had $1 as its overridden IR symbol, just because
FIR declaration of $3 doesn't know anything about $2.

Now, when generating IR for $2, we save the necessary information
and using it for $3, so it has $2 as overridden.

So, it's consistent with the overridden structure of FE 1.0 and this
structure is necessary prerequisite for proper building of bridges
for special built-ins.
2021-02-20 10:59:22 +03:00

25 lines
711 B
Kotlin
Vendored

abstract class AbstractAdd {
abstract fun add(s: String): Any
}
abstract class AbstractStringCollection : AbstractAdd(), Collection<String>
class StringCollection : AbstractStringCollection() {
override fun add(s: String) = s
override val size: Int get() = TODO()
override fun contains(element: String): Boolean = TODO()
override fun containsAll(elements: Collection<String>): Boolean = TODO()
override fun isEmpty(): Boolean = TODO()
override fun iterator(): Iterator<String> = TODO()
}
fun test1(a: AbstractAdd) =
a.add("O") as String
fun test2(a: AbstractStringCollection) =
a.add("K") as String
fun box() =
test1(StringCollection()) + test2(StringCollection())