[Tests] Migrate backend-independent tests from native to compiler/testData.
^KT-65979
This commit is contained in:
committed by
Space Team
parent
dd9332d9e1
commit
febac0dd5f
@@ -1,31 +0,0 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package a
|
||||
|
||||
interface A<T> {
|
||||
fun foo(): T
|
||||
}
|
||||
|
||||
open class C: A<Int> {
|
||||
override fun foo(): Int = 42
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
import a.*
|
||||
import kotlin.test.*
|
||||
|
||||
class B: C()
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
assertEquals(42, b.foo())
|
||||
val c: C = b
|
||||
assertEquals(42, c.foo())
|
||||
val a: A<Int> = b
|
||||
assertEquals(42, a.foo())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
sealed class Tag {
|
||||
abstract fun value(): Any
|
||||
}
|
||||
|
||||
sealed class TagBoolean : Tag() {
|
||||
abstract override fun value(): String
|
||||
|
||||
object True : TagBoolean() {
|
||||
override fun value() = "OK"
|
||||
}
|
||||
|
||||
object False : TagBoolean() {
|
||||
override fun value() = "FAIL"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = TagBoolean.True.value()
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class A { }
|
||||
|
||||
class B { }
|
||||
|
||||
class C { }
|
||||
|
||||
interface Parser<in IN: Any, out OUT: Any> {
|
||||
fun parse(source: IN): OUT
|
||||
}
|
||||
|
||||
interface MultiParser<in IN: Any, out OUT: Any> {
|
||||
fun parse(source: IN): Collection<OUT>
|
||||
}
|
||||
|
||||
interface ExtendsInterface<T: Any>: Parser<A, T>, MultiParser<B, T> {
|
||||
override fun parse(source: B): Collection<T> = ArrayList<T>()
|
||||
}
|
||||
|
||||
abstract class AbstractClass(): ExtendsInterface<C> {
|
||||
public override fun parse(source: A): C = C()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val array = object : AbstractClass() { }.parse(B())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
private object NotEmptyMap : MutableMap<Any, Int> {
|
||||
override fun containsKey(key: Any): Boolean = true
|
||||
override fun containsValue(value: Int): Boolean = true
|
||||
|
||||
// non-special bridges get(Object)Integer -> get(Object)I
|
||||
override fun get(key: Any): Int = 1
|
||||
override fun remove(key: Any): Int = 1
|
||||
|
||||
override val size: Int get() = 0
|
||||
override fun isEmpty(): Boolean = true
|
||||
override fun put(key: Any, value: Int): Int? = throw UnsupportedOperationException()
|
||||
override fun putAll(from: Map<out Any, Int>): Unit = throw UnsupportedOperationException()
|
||||
override fun clear(): Unit = throw UnsupportedOperationException()
|
||||
override val entries: MutableSet<MutableMap.MutableEntry<Any, Int>> get() = null!!
|
||||
override val keys: MutableSet<Any> get() = null!!
|
||||
override val values: MutableCollection<Int> get() = null!!
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val n = NotEmptyMap as MutableMap<Any?, Any?>
|
||||
|
||||
if (n.get(null) != null) return "FAIL 1: $n"
|
||||
if (n.containsKey(null)) return "FAIL 2: $n"
|
||||
if (n.containsValue(null)) return "FAIL 3: $n"
|
||||
if (n.remove(null) != null) return "FAIL 4: $n"
|
||||
|
||||
if (n.get(1) == null) return "FAIL 5: $n"
|
||||
if (!n.containsKey("")) return "FAIL 6: $n"
|
||||
if (!n.containsValue(3)) return "FAIL 7: $n"
|
||||
if (n.remove("") == null) return "FAIL 8: $n"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
interface Element {
|
||||
val isContained: Boolean
|
||||
}
|
||||
|
||||
object ContainedElement : Element {
|
||||
override val isContained: Boolean = true
|
||||
}
|
||||
|
||||
object NotContainedElement : Element {
|
||||
override val isContained: Boolean = false
|
||||
}
|
||||
|
||||
internal class MySet<E : Element> : Set<E> {
|
||||
override fun contains(element: E): Boolean = element.isContained
|
||||
|
||||
override fun equals(other: Any?): Boolean = TODO()
|
||||
override fun hashCode(): Int = TODO()
|
||||
override fun toString(): String = TODO()
|
||||
|
||||
override val size: Int get() = TODO()
|
||||
override fun isEmpty(): Boolean = TODO()
|
||||
override fun containsAll(elements: Collection<E>): Boolean = TODO()
|
||||
|
||||
override fun iterator(): Iterator<E> = TODO()
|
||||
}
|
||||
|
||||
fun set(): Set<Any> = MySet<Element>()
|
||||
|
||||
fun box(): String {
|
||||
val set = set()
|
||||
if (set.contains(Any())) return "FAIL 1: $set"
|
||||
if (set.contains(NotContainedElement)) return "FAIL 2: $set"
|
||||
if (!set.contains(ContainedElement)) return "FAIL 3: $set"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// vtable call
|
||||
open class A {
|
||||
open fun foo(): Any = "A"
|
||||
}
|
||||
|
||||
open class C : A() {
|
||||
override fun foo(): Int = 42
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = C()
|
||||
val a: A = c
|
||||
val res1 = c.foo().toString()
|
||||
if (res1 != "42") return "FAIL 1: $res1"
|
||||
val res2 = a.foo().toString()
|
||||
if (res2 != "42") return "FAIL 2: $res2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// interface call, bridge overridden
|
||||
interface Z1 {
|
||||
fun foo(x: Int) : Any
|
||||
}
|
||||
|
||||
open class A : Z1 {
|
||||
override fun foo(x: Int) : Int = 5
|
||||
}
|
||||
|
||||
open class B : A() {
|
||||
override fun foo(x: Int) : Int = 42
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val z1: A = B()
|
||||
val res = (z1.foo(1) + 1000).toString()
|
||||
if (res != "1042") return "FAIL: $res"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
open class A<T> {
|
||||
open fun foo(x: T) {
|
||||
sb.appendLine(x.toString())
|
||||
}
|
||||
}
|
||||
|
||||
interface I {
|
||||
fun foo(x: Int)
|
||||
}
|
||||
|
||||
class B : A<Int>(), I {
|
||||
var z: Int = 5
|
||||
override fun foo(x: Int) {
|
||||
z = x
|
||||
}
|
||||
}
|
||||
|
||||
fun zzz(a: A<Int>) {
|
||||
a.foo(42)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
zzz(b)
|
||||
val a = A<Int>()
|
||||
zzz(a)
|
||||
sb.appendLine(b.z.toString())
|
||||
|
||||
assertEquals("42\n42\n", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
interface I {
|
||||
fun foo(x: Int)
|
||||
}
|
||||
|
||||
abstract class A<T> {
|
||||
abstract fun foo(x: T)
|
||||
}
|
||||
|
||||
class B : A<Int>(), I {
|
||||
override fun foo(x: Int) {
|
||||
sb.appendLine(x)
|
||||
Unit
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
val a: A<Int> = b
|
||||
val c: I = b
|
||||
b.foo(42)
|
||||
a.foo(42)
|
||||
c.foo(42)
|
||||
|
||||
assertEquals("42\n42\n42\n", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
abstract class A<in T> {
|
||||
abstract fun foo(x: T)
|
||||
}
|
||||
|
||||
class B : A<Int>() {
|
||||
override fun foo(x: Int) {
|
||||
sb.appendLine("B: $x")
|
||||
}
|
||||
}
|
||||
|
||||
class C : A<Any>() {
|
||||
override fun foo(x: Any) {
|
||||
sb.appendLine("C: $x")
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(arg: A<Int>) {
|
||||
arg.foo(42)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
foo(B())
|
||||
foo(C())
|
||||
|
||||
assertEquals("B: 42\nC: 42\n", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
open class A<T> {
|
||||
open fun T.foo() {
|
||||
sb.appendLine(this.toString())
|
||||
}
|
||||
|
||||
fun bar(x: T) {
|
||||
x.foo()
|
||||
}
|
||||
}
|
||||
|
||||
open class B: A<Int>() {
|
||||
override fun Int.foo() {
|
||||
sb.appendLine(this.toString())
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
val a = A<Int>()
|
||||
b.bar(42)
|
||||
a.bar(42)
|
||||
|
||||
assertEquals("42\n42\n", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
open class A<T, U> {
|
||||
open fun foo(x: T, y: U) {
|
||||
sb.appendLine(x.toString())
|
||||
sb.appendLine(y.toString())
|
||||
}
|
||||
}
|
||||
|
||||
interface I1<T> {
|
||||
fun foo(x: Int, y: T)
|
||||
}
|
||||
|
||||
interface I2<T> {
|
||||
fun foo(x: T, y: Int)
|
||||
}
|
||||
|
||||
class B : A<Int, Int>(), I1<Int>, I2<Int> {
|
||||
var z: Int = 5
|
||||
var q: Int = 7
|
||||
override fun foo(x: Int, y: Int) {
|
||||
z = x
|
||||
q = y
|
||||
}
|
||||
}
|
||||
|
||||
fun zzz(a: A<Int, Int>) {
|
||||
a.foo(42, 56)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
zzz(b)
|
||||
val a = A<Int, Int>()
|
||||
zzz(a)
|
||||
sb.appendLine(b.z.toString())
|
||||
sb.appendLine(b.q.toString())
|
||||
val i1: I1<Int> = b
|
||||
i1.foo(56, 42)
|
||||
sb.appendLine(b.z.toString())
|
||||
sb.appendLine(b.q.toString())
|
||||
val i2: I2<Int> = b
|
||||
i2.foo(156, 142)
|
||||
sb.appendLine(b.z.toString())
|
||||
sb.appendLine(b.q.toString())
|
||||
|
||||
assertEquals("""
|
||||
42
|
||||
56
|
||||
42
|
||||
56
|
||||
56
|
||||
42
|
||||
156
|
||||
142
|
||||
|
||||
""".trimIndent(), sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// non-generic interface, generic impl, vtable call + interface call
|
||||
open class A<T> {
|
||||
open var size: T = 56 as T
|
||||
}
|
||||
|
||||
interface C {
|
||||
var size: Int
|
||||
}
|
||||
|
||||
open class B : C, A<Int>()
|
||||
|
||||
open class D: B() {
|
||||
override var size: Int = 117
|
||||
}
|
||||
|
||||
fun <T> foo(a: A<T>) {
|
||||
a.size = 42 as T
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
|
||||
foo(b)
|
||||
if (b.size != 42) return "fail 1"
|
||||
val d = D()
|
||||
if (d.size != 117) return "fail 2"
|
||||
foo(d)
|
||||
if (d.size != 42) return "fail 3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
interface A {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
abstract class C: A
|
||||
|
||||
open class B: C() {
|
||||
override fun foo(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(c: C) = c.foo()
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
val c: C = b
|
||||
val barb = bar(b)
|
||||
if (barb != "OK") return "FAIL b: $barb"
|
||||
|
||||
val barc = bar(c)
|
||||
if (barc != "OK") return "FAIL c: $barc"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// abstract bridge
|
||||
interface A<T> {
|
||||
fun foo(): T
|
||||
}
|
||||
|
||||
abstract class B<T>: A<T>
|
||||
|
||||
abstract class C: B<Int>()
|
||||
|
||||
class D: C() {
|
||||
override fun foo(): Int {
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val d = D()
|
||||
val c: C = d
|
||||
val b: B<Int> = d
|
||||
val a: A<Int> = d
|
||||
val foo0 = d.foo()
|
||||
if (foo0 != 42) return "FAIL d: $foo0"
|
||||
val foo1 = c.foo()
|
||||
if (foo1 != 42) return "FAIL c: $foo1"
|
||||
val foo2 = b.foo()
|
||||
if (foo2 != 42) return "FAIL b: $foo2"
|
||||
val foo3 = a.foo()
|
||||
if (foo3 != 42) return "FAIL a: $foo3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// overriden function returns Unit
|
||||
open class A {
|
||||
open fun foo(): Any = 42
|
||||
}
|
||||
|
||||
open class B: A() {
|
||||
override fun foo(): Unit { }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a: A = B()
|
||||
val afoo = a.foo()
|
||||
if (afoo != Unit) return "FAIL $afoo"
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// vtable call, bridge inherited
|
||||
open class A {
|
||||
open fun foo(): Any = "A"
|
||||
}
|
||||
|
||||
open class C : A() {
|
||||
override fun foo(): Int = 42
|
||||
}
|
||||
|
||||
open class D: C()
|
||||
|
||||
fun box(): String {
|
||||
val c = D()
|
||||
val a: A = c
|
||||
val res1 = c.foo().toString()
|
||||
if (res1 != "42") return "FAIL 1: $res1"
|
||||
val res2 = a.foo().toString()
|
||||
if (res2 != "42") return "FAIL 2: $res2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// non-generic interface, generic impl, non-virtual call + interface call
|
||||
open class A<T> {
|
||||
var size: T = 56 as T
|
||||
}
|
||||
|
||||
interface C {
|
||||
var size: Int
|
||||
}
|
||||
|
||||
class B : C, A<Int>()
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
if (b.size != 56) return "fail 1"
|
||||
|
||||
b.size = 55
|
||||
if (b.size != 55) return "fail 2"
|
||||
|
||||
val c: C = b
|
||||
if (c.size != 55) return "fail 3"
|
||||
|
||||
c.size = 57
|
||||
if (c.size != 57) return "fail 4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// vtable call + interface call
|
||||
interface Z {
|
||||
fun foo(): Any
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun foo(): Int
|
||||
}
|
||||
|
||||
open class A {
|
||||
fun foo(): Int = 42
|
||||
}
|
||||
|
||||
open class B: A(), Z, Y
|
||||
|
||||
fun box(): String {
|
||||
val z: Z = B()
|
||||
val y: Y = z as Y
|
||||
val res1 = z.foo().toString()
|
||||
if (res1 != "42") return "FAIL 1: $res1"
|
||||
val res2 = y.foo().toString()
|
||||
if (res2 != "42") return "FAIL 2: $res2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// non-generic interface, generic impl, vtable call + interface call
|
||||
open class A<T> {
|
||||
open var size: T = 56 as T
|
||||
}
|
||||
|
||||
interface C {
|
||||
var size: Int
|
||||
}
|
||||
|
||||
open class B : C, A<Int>()
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
if (b.size != 56) return "fail 1"
|
||||
|
||||
b.size = 55
|
||||
if (b.size != 55) return "fail 2"
|
||||
|
||||
val c: C = b
|
||||
if (c.size != 55) return "fail 3"
|
||||
|
||||
c.size = 57
|
||||
if (c.size != 57) return "fail 4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// vtable call + interface call
|
||||
interface Z {
|
||||
fun foo(): Any
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun foo(): Int
|
||||
}
|
||||
|
||||
open class A {
|
||||
open fun foo(): Any = "A"
|
||||
}
|
||||
|
||||
open class C : A() {
|
||||
override fun foo(): Int = 42
|
||||
}
|
||||
|
||||
open class D: C(), Y, Z
|
||||
|
||||
fun box(): String {
|
||||
val d = D()
|
||||
val y: Y = d
|
||||
val z: Z = d
|
||||
val c: C = d
|
||||
val a: A = d
|
||||
if (d.foo().toString() != "42") return "FAIL 1"
|
||||
if (y.foo().toString() != "42") return "FAIL 2"
|
||||
if (z.foo().toString() != "42") return "FAIL 3"
|
||||
if (c.foo().toString() != "42") return "FAIL 4"
|
||||
if (a.foo().toString() != "42") return "FAIL 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// generic interface, non-generic impl, vtable call + interface call
|
||||
open class A {
|
||||
open var size: Int = 56
|
||||
}
|
||||
|
||||
interface C<T> {
|
||||
var size: T
|
||||
}
|
||||
|
||||
open class B : C<Int>, A()
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
if (b.size != 56) return "fail 1"
|
||||
|
||||
b.size = 55
|
||||
if (b.size != 55) return "fail 2"
|
||||
|
||||
val c: C<Int> = b
|
||||
if (c.size != 55) return "fail 3"
|
||||
|
||||
c.size = 57
|
||||
if (c.size != 57) return "fail 4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// generic interface, non-generic impl, non-virtual call + interface call
|
||||
open class A {
|
||||
var size: Int = 56
|
||||
}
|
||||
|
||||
interface C<T> {
|
||||
var size: T
|
||||
}
|
||||
|
||||
class B : C<Int>, A()
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
if (b.size != 56) return "fail 1"
|
||||
|
||||
b.size = 55
|
||||
if (b.size != 55) return "fail 2"
|
||||
|
||||
val c: C<Int> = b
|
||||
if (c.size != 55) return "fail 3"
|
||||
|
||||
c.size = 57
|
||||
if (c.size != 57) return "fail 4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// abstract class vtable call
|
||||
abstract class A {
|
||||
abstract fun foo(): String
|
||||
}
|
||||
|
||||
abstract class B : A()
|
||||
|
||||
class Z : B() {
|
||||
override fun foo() = "Z"
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val z = Z()
|
||||
val b: B = z
|
||||
val a: A = z
|
||||
return when {
|
||||
z.foo() != "Z" -> "Fail #1"
|
||||
b.foo() != "Z" -> "Fail #2"
|
||||
a.foo() != "Z" -> "Fail #3"
|
||||
else -> "OK"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user