Move JVM8 box test to common
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: IBase.java
|
||||
|
||||
interface IBase {
|
||||
default String bar() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Kotlin.kt
|
||||
// JVM_TARGET: 1.8
|
||||
open class Base {
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
class C : Base(), IBase {
|
||||
val lambda1 = {
|
||||
super.foo()
|
||||
}
|
||||
|
||||
val lambda2 = {
|
||||
super.bar()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (C().lambda1() != "OK") return "fail 1"
|
||||
|
||||
return C().lambda2()
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
public interface Simple {
|
||||
default String test(String s) {
|
||||
return s + "K";
|
||||
}
|
||||
|
||||
static String testStatic(String s) {
|
||||
return s + "K";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
interface KInterface : Simple {
|
||||
fun bar(): String {
|
||||
return test("O") + Simple.testStatic("O")
|
||||
}
|
||||
}
|
||||
|
||||
class Test : KInterface {}
|
||||
|
||||
fun box(): String {
|
||||
val test = Test().bar()
|
||||
if (test != "OKOK") return "fail $test"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
interface Simple {
|
||||
default String test(String s) {
|
||||
return s + "K";
|
||||
}
|
||||
|
||||
static String testStatic(String s) {
|
||||
return s + "K";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
class Test : Simple {}
|
||||
|
||||
fun box(): String {
|
||||
val test = Test().test("O")
|
||||
if (test != "OK") return "fail $test"
|
||||
|
||||
return Simple.testStatic("O")
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
public interface Simple {
|
||||
default String test(String s) {
|
||||
return s + "K";
|
||||
}
|
||||
|
||||
static String testStatic(String s) {
|
||||
return s + "K";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
interface TestInterface : Simple {}
|
||||
class Test : TestInterface {}
|
||||
|
||||
fun box(): String {
|
||||
val test = Test().test("O")
|
||||
if (test != "OK") return "fail $test"
|
||||
|
||||
return Simple.testStatic("O")
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
public interface Simple {
|
||||
default String test(String s) {
|
||||
return s + "Fail";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface KInterface: Simple {
|
||||
override fun test(s: String): String {
|
||||
return s + "K"
|
||||
}
|
||||
}
|
||||
|
||||
class Test : KInterface {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Test().test("O")
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Test.java
|
||||
|
||||
interface Test<T> {
|
||||
|
||||
T call();
|
||||
|
||||
default T testDefault(T p) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
class Child : Test<String> {
|
||||
override fun call() : String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
fun box(): String {
|
||||
val res = Child().call()
|
||||
if (res != "OK") return "fail $res"
|
||||
|
||||
return Child().testDefault("OK")
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Simple.java
|
||||
|
||||
interface Simple extends KInterface {
|
||||
default String test() {
|
||||
return "simple";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// JVM_TARGET: 1.8
|
||||
interface KInterface {
|
||||
fun test(): String {
|
||||
return "base";
|
||||
}
|
||||
}
|
||||
|
||||
class Test : Simple {
|
||||
fun bar(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val test = Test().test()
|
||||
if (test != "simple") return "fail $test"
|
||||
|
||||
val bar = Test().bar()
|
||||
if (bar != "simple") return "fail 2 $bar"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Test.java
|
||||
|
||||
public interface Test {
|
||||
default String test() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
// JVM_TARGET: 1.8
|
||||
interface KInterface : Test {
|
||||
|
||||
}
|
||||
|
||||
class KClass : Test {
|
||||
fun ktest(): String {
|
||||
return super.test() + test()
|
||||
}
|
||||
}
|
||||
|
||||
class KTClass : KInterface {
|
||||
fun ktest(): String {
|
||||
return super.test() + test()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val p = object : KInterface {
|
||||
fun ktest(): String {
|
||||
return super.test() + test()
|
||||
}
|
||||
}.ktest()
|
||||
|
||||
if (p != "OKOK") return "fail1: $p"
|
||||
|
||||
if (KClass().ktest() != "OKOK") return "fail 2: ${KClass().ktest()}"
|
||||
|
||||
if (KTClass().ktest() != "OKOK") return "fail 3: ${KTClass().ktest()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Test.java
|
||||
|
||||
public interface Test {
|
||||
default String test() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
interface KInterface : Test {
|
||||
|
||||
}
|
||||
|
||||
class KClass : Test {
|
||||
@kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR")
|
||||
fun ktest(): String {
|
||||
return super.test() + test()
|
||||
}
|
||||
}
|
||||
|
||||
class KTClass : KInterface {
|
||||
@kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR")
|
||||
fun ktest(): String {
|
||||
return super.test() + test()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val p = object : KInterface {
|
||||
@kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR")
|
||||
fun ktest(): String {
|
||||
return super.test() + test()
|
||||
}
|
||||
}.ktest()
|
||||
|
||||
if (p != "OKOK") return "fail1: $p"
|
||||
|
||||
if (KClass().ktest() != "OKOK") return "fail 2: ${KClass().ktest()}"
|
||||
|
||||
if (KTClass().ktest() != "OKOK") return "fail 3: ${KTClass().ktest()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Base.java
|
||||
|
||||
public interface Base {
|
||||
default String foo() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: derived.kt
|
||||
// JVM_TARGET: 1.8
|
||||
interface K1 : Base
|
||||
|
||||
interface K2 : K1
|
||||
|
||||
interface K3 : K2
|
||||
|
||||
class C : K3 {
|
||||
override fun foo() = super.foo()
|
||||
}
|
||||
|
||||
fun box(): String = C().foo()
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: JavaCall.java
|
||||
|
||||
class JavaCall {
|
||||
String call(Test test) {
|
||||
return test.call();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Test.java
|
||||
|
||||
interface Test {
|
||||
|
||||
String call();
|
||||
|
||||
default String test() {
|
||||
return "K";
|
||||
}
|
||||
|
||||
static String testStatic() {
|
||||
return "K";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: sam.kt
|
||||
|
||||
fun box(): String {
|
||||
return JavaCall().call {"OK"}
|
||||
}
|
||||
Reference in New Issue
Block a user