Files
kotlin-fork/compiler/testData/ir/irText/fakeOverrides/generics/genericWithBoundsOnComplexHierarchy.kt.txt
T
anzhela.sukhanova 82255d5ee8 [Test] KT-61360: add tests for the IrFakeOverrideBuilder
Add tests for fake overrides with focus on java interoperability

Co-authored-by: Aleksandra Arsenteva <aleksandra.arsenteva@jetbrains.com>
2024-03-04 16:21:02 +00:00

139 lines
2.1 KiB
Kotlin
Vendored

class A : Java2 {
constructor() /* primary */ {
super/*Java2*/()
/* <init>() */
}
}
abstract class B : KotlinClass<Int>, Java3 {
constructor() /* primary */ {
super/*KotlinClass*/<Int>()
/* <init>() */
}
}
class C : KotlinClass<Int>, Java3 {
constructor() /* primary */ {
super/*KotlinClass*/<Int>()
/* <init>() */
}
override fun foo(t: Any?) {
}
}
abstract class D : Java4<Any>, Java3 {
constructor() /* primary */ {
super/*Java4*/<@FlexibleNullability Any?>()
/* <init>() */
}
}
class E : Java4<Any>, Java3 {
constructor() /* primary */ {
super/*Java4*/<@FlexibleNullability Any?>()
/* <init>() */
}
override fun foo(t: Any?) {
}
}
abstract class F : Java1<Int>, Java5 {
constructor() /* primary */ {
super/*Java1*/<@FlexibleNullability Int?>()
/* <init>() */
}
}
class G : Java1<Int>, Java5 {
constructor() /* primary */ {
super/*Java1*/<@FlexibleNullability Int?>()
/* <init>() */
}
override fun foo(t: Any) {
}
}
class H : Java2, KotlinInterface<Any> {
constructor() /* primary */ {
super/*Java2*/()
/* <init>() */
}
}
class I : Java2, KotlinInterface<Any> {
constructor() /* primary */ {
super/*Java2*/()
/* <init>() */
}
override fun foo(t: Any) {
}
}
open class KotlinClass<T> : Java1<T> where T : Number, T : Comparable<T> {
constructor() /* primary */ {
super/*Java1*/<@FlexibleNullability T?>()
/* <init>() */
}
}
interface KotlinInterface<T : Any> {
abstract fun bar(): T?
abstract fun foo(t: T)
}
fun test(a: A, b: B, c: C, d: D, e: E, f: F, h: H, i: I) {
a.foo(t = 1)
a.foo(t = 1.1)
a.foo(t = null)
a.foo(t = "")
a.bar() /*~> Unit */
b.foo(t = 1.2)
b.foo(t = null)
b.bar() /*~> Unit */
c.foo(t = null)
c.foo(t = "")
c.foo(t = 1)
c.bar() /*~> Unit */
d.foo(t = null)
d.foo(t = 1)
d.bar() /*~> Unit */
e.foo(t = 1.1)
e.foo(t = null)
e.bar() /*~> Unit */
f.foo(t = 2)
f.foo(t = "")
f.bar() /*~> Unit */
h.foo(t = 2)
h.foo(t = "")
h.bar() /*~> Unit */
i.foo(t = 2)
i.foo(t = "")
i.bar() /*~> Unit */
}