Add new tests
This commit is contained in:
committed by
Mikhail Bogdanov
parent
0570c05683
commit
0c0bd67a6b
@@ -0,0 +1,38 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
public interface Simple extends KInterface2 {
|
||||
default String test() {
|
||||
return KInterface2.DefaultImpls.test2(this, "OK");
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Foo.java
|
||||
public class Foo implements Simple {
|
||||
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface KInterface<T> {
|
||||
fun test2(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
interface KInterface2 : KInterface<String> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
|
||||
val result = Foo().test()
|
||||
if (result != "OK") return "fail 1: ${result}"
|
||||
|
||||
return Foo().test2("OK")
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
public interface Simple extends KInterface2 {
|
||||
default String test() {
|
||||
return KInterface2.DefaultImpls.test2(this, "OK");
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Foo.java
|
||||
public class Foo implements Simple {
|
||||
public String test2(String p) {
|
||||
return "fail";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface KInterface<T> {
|
||||
fun test2(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
interface KInterface2 : KInterface<String> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return Foo().test()
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
public interface Simple extends KInterface3 {
|
||||
default String test() {
|
||||
return KInterface3.DefaultImpls.test2(this, "OK");
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Foo.java
|
||||
public class Foo implements Simple {
|
||||
public String test2(String p) {
|
||||
return "fail";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface KInterface<T> {
|
||||
fun test2(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
interface KInterface2 : KInterface<String> {
|
||||
|
||||
}
|
||||
|
||||
interface KInterface3 : KInterface2 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return Foo().test()
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
public interface Simple extends KInterface2 {
|
||||
default String test() {
|
||||
return KInterface2.DefaultImpls.getBar(this);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Foo.java
|
||||
public class Foo implements Simple {
|
||||
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface KInterface<T> {
|
||||
|
||||
val foo: T
|
||||
|
||||
val bar: T
|
||||
get() = foo
|
||||
}
|
||||
|
||||
interface KInterface2 : KInterface<String> {
|
||||
override val foo: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
|
||||
val result = Foo().test()
|
||||
if (result != "OK") return "fail 1: ${result}"
|
||||
|
||||
return Foo().bar
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
public interface Simple extends KInterface2 {
|
||||
default String test() {
|
||||
return KInterface2.DefaultImpls.getBar(this);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Foo.java
|
||||
public class Foo implements Simple {
|
||||
public String getBar() {
|
||||
return "fail";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface KInterface<T> {
|
||||
|
||||
val foo: T
|
||||
|
||||
val bar: T
|
||||
get() = foo
|
||||
}
|
||||
|
||||
interface KInterface2 : KInterface<String> {
|
||||
override val foo: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return Foo().test()
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
public interface Simple extends KInterface3 {
|
||||
default String test() {
|
||||
return KInterface3.DefaultImpls.getBar(this);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Foo.java
|
||||
public class Foo implements Simple {
|
||||
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface KInterface<T> {
|
||||
|
||||
val foo: T
|
||||
|
||||
val bar: T
|
||||
get() = foo
|
||||
}
|
||||
|
||||
interface KInterface2 : KInterface<String> {
|
||||
override val foo: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
interface KInterface3 : KInterface2 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return Foo().test()
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// FULL_JDK
|
||||
// WITH_RUNTIME
|
||||
// FILE: Simple.java
|
||||
|
||||
public interface Simple extends KInterface {
|
||||
default java.util.List<String> compatibilityCall() {
|
||||
return KInterface.DefaultImpls.call(this);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Foo.java
|
||||
public class Foo implements Simple {
|
||||
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface KInterface {
|
||||
fun call(): List<String> {
|
||||
return Thread.currentThread().getStackTrace().map { it.className + "." + it.methodName }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
var result = Foo().compatibilityCall()
|
||||
if (result[1] != "KInterface.call") return "fail 1: ${result[1]}"
|
||||
if (result[2] != "KInterface.access\$call\$jd") return "fail 2: ${result[2]}"
|
||||
if (result[3] != "KInterface\$DefaultImpls.call") return "fail 3: ${result[3]}"
|
||||
if (result[4] != "Simple.compatibilityCall") return "fail 4: ${result[4]}"
|
||||
if (result[5] != "MainKt.box") return "fail 5: ${result[5]}"
|
||||
|
||||
result = Foo().call()
|
||||
if (result[1] != "KInterface.call") return "fail 1: ${result[1]}"
|
||||
if (result[2] != "MainKt.box") return "fail 2: ${result[2]}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// FULL_JDK
|
||||
|
||||
interface Test {
|
||||
fun test(s: String ="OK"): String {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val defaultImpls = java.lang.Class.forName(Test::class.java.canonicalName + "\$DefaultImpls")
|
||||
|
||||
val declaredMethod = defaultImpls.getDeclaredMethod("test\$default", Test::class.java, String::class.java, Int::class.java, Any::class.java)
|
||||
return declaredMethod.invoke(null, TestClass(), null, 1, null) as String
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface A {
|
||||
fun foo(x: String = "OK"): String {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = object : A {}
|
||||
return x.foo()
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
interface I {
|
||||
fun foo(x: String = "OK"): String = x
|
||||
}
|
||||
|
||||
interface J : I
|
||||
|
||||
object O : J
|
||||
|
||||
fun box(): String = O.foo()
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
public interface Simple extends KInterface2 {
|
||||
default String test() {
|
||||
return KInterface2.DefaultImpls.test2(this);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Foo.java
|
||||
public class Foo implements Simple {
|
||||
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface KInterface {
|
||||
fun test2(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
interface KInterface2 : KInterface {
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val result = Foo().test()
|
||||
if (result != "OK") return "fail 1: ${result}"
|
||||
|
||||
return Foo().test2()
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
interface A {
|
||||
fun String.foo(k: String) = "O" + k
|
||||
}
|
||||
|
||||
fun box(): String =
|
||||
object : A {
|
||||
fun box() = "FAIL".foo("K")
|
||||
}.box()
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_REFLECT
|
||||
|
||||
annotation class Property(val value: String)
|
||||
annotation class Accessor(val value: String)
|
||||
|
||||
interface Z {
|
||||
@Property("OK")
|
||||
val z: String
|
||||
@Accessor("OK")
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
|
||||
class Test : Z
|
||||
|
||||
fun box() : String {
|
||||
val value = Z::z.annotations.filterIsInstance<Property>().single().value
|
||||
if (value != "OK") return value
|
||||
return (Z::z.getter.annotations.single() as Accessor).value
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
public interface Simple extends KInterface {
|
||||
default String test() {
|
||||
return KInterface.DefaultImpls.test2(this);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Foo.java
|
||||
public class Foo implements Simple {
|
||||
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface KInterface {
|
||||
fun test2(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val result = Foo().test()
|
||||
if (result != "OK") return "fail 1: ${result}"
|
||||
|
||||
return Foo().test2()
|
||||
}
|
||||
Reference in New Issue
Block a user