JvmDefault: remove most tests on @JvmDefault
The tests are removed because JvmDefault is going to be deprecated with error in KT-54746 and removed later in KT-57696. Many of the removed tests already had existing counterparts with the new modes `all` and `all-compatibility`. In this change, I've added such tests where they were missing, and removed tests which were testing behavior specific to the JvmDefault annotation, such as some diagnostics. #KT-54746
This commit is contained in:
committed by
Space Team
parent
ace2279631
commit
3120a35a88
+1
-2
@@ -1,4 +1,4 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// SKIP_JDK6
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
@@ -14,7 +14,6 @@ class B : A<String, String>, java.util.AbstractMap<String, String>() {
|
||||
}
|
||||
|
||||
interface C<K, V> : MutableMap<K, V> {
|
||||
@JvmDefault
|
||||
override fun remove(key: K, value: V) = true
|
||||
}
|
||||
|
||||
|
||||
+3
-16
@@ -6,24 +6,11 @@
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "O"
|
||||
}
|
||||
|
||||
fun delegatedTest(): String {
|
||||
return "fail"
|
||||
}
|
||||
fun test(): String = "Fail"
|
||||
}
|
||||
|
||||
class Delegate : Test {
|
||||
override fun test(): String {
|
||||
return "Fail"
|
||||
}
|
||||
|
||||
override fun delegatedTest(): String {
|
||||
return "K"
|
||||
}
|
||||
override fun test(): String = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
@@ -32,5 +19,5 @@ class TestClass(val foo: Test) : Test by foo
|
||||
|
||||
fun box(): String {
|
||||
val testClass = TestClass(Delegate())
|
||||
return testClass.test() + testClass.delegatedTest()
|
||||
return testClass.test()
|
||||
}
|
||||
|
||||
+3
-13
@@ -6,21 +6,11 @@
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
val test: String
|
||||
get() = "O"
|
||||
|
||||
val testDelegated: String
|
||||
get() = "fail"
|
||||
|
||||
val test: String get() = "Fail"
|
||||
}
|
||||
|
||||
class Delegate : Test {
|
||||
override val test: String
|
||||
get() = "fail"
|
||||
|
||||
override val testDelegated: String
|
||||
get() = "K"
|
||||
override val test: String get() = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
@@ -29,5 +19,5 @@ class TestClass(val foo: Test) : Test by foo
|
||||
|
||||
fun box(): String {
|
||||
val testClass = TestClass(Delegate())
|
||||
return testClass.test + testClass.testDelegated
|
||||
return testClass.test
|
||||
}
|
||||
|
||||
+5
-8
@@ -1,11 +1,10 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// FULL_JDK
|
||||
// WITH_STDLIB
|
||||
// JVM_TARGET: 1.8
|
||||
// MODULE: lib
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// FILE: 1.kt
|
||||
interface KInterface {
|
||||
@JvmDefault
|
||||
fun call(): List<String> {
|
||||
return Thread.currentThread().getStackTrace().map { it.className + "." + it.methodName }
|
||||
}
|
||||
@@ -14,10 +13,9 @@ interface KInterface {
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// FILE: main.kt
|
||||
interface KInterface2 : KInterface {
|
||||
override fun superCall() = super.superCall()
|
||||
|
||||
}
|
||||
|
||||
class Foo: KInterface2 {
|
||||
@@ -30,10 +28,9 @@ fun box(): String {
|
||||
if (result[2] != "MainKt.box") return "fail 2: ${result[2]}"
|
||||
|
||||
result = Foo().superCall2()
|
||||
if (result[1] != "KInterface\$DefaultImpls.superCall") return "fail 1: ${result[1]}"
|
||||
if (result[2] != "KInterface2.superCall") return "fail 2: ${result[2]}"
|
||||
if (result[3] != "Foo.superCall2") return "fail 3: ${result[3]}"
|
||||
if (result[4] != "MainKt.box") return "fail 4: ${result[4]}"
|
||||
if (result[1] != "KInterface.superCall") return "fail 1: ${result[1]}"
|
||||
if (result[2] != "Foo.superCall2") return "fail 2: ${result[2]}"
|
||||
if (result[3] != "MainKt.box") return "fail 3: ${result[3]}"
|
||||
|
||||
|
||||
return "OK"
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
val prop: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
interface Test2 : Test {
|
||||
override val prop: String
|
||||
get() = super.prop
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return object : Test2 {}.prop
|
||||
}
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Vendored
+1
-3
@@ -1,10 +1,9 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
@@ -14,7 +13,6 @@ interface Test {
|
||||
// FILE: 2.kt
|
||||
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
|
||||
Vendored
-29
@@ -1,29 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun defaultImplTrigger(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return object : Test2 {}.test()
|
||||
}
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
val prop: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
+1
-3
@@ -1,10 +1,9 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
val prop: String
|
||||
get() = "OK"
|
||||
}
|
||||
@@ -12,7 +11,6 @@ interface Test {
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override val prop: String
|
||||
get() = super.prop
|
||||
}
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
val prop: String
|
||||
get() = "OK"
|
||||
|
||||
val defaultImplTrigger: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override val prop: String
|
||||
get() = super.prop
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return object : Test2 {}.prop
|
||||
}
|
||||
Vendored
+2
-3
@@ -1,5 +1,5 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// MODULE: lib
|
||||
// !JVM_DEFAULT_MODE: disable
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
@@ -8,11 +8,11 @@ interface Test {
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FILE: 2.kt
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
@@ -24,7 +24,6 @@ interface Test3 : Test {
|
||||
|
||||
|
||||
interface Test4 : Test2, Test3 {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// MODULE: lib
|
||||
// !JVM_DEFAULT_MODE: disable
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
@@ -8,6 +8,7 @@ interface Test {
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FILE: 2.kt
|
||||
@@ -18,7 +19,6 @@ open class TestClass : Test {
|
||||
}
|
||||
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// MODULE: lib
|
||||
// !JVM_DEFAULT_MODE: disable
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
@@ -8,6 +8,7 @@ interface Test {
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FILE: 2.kt
|
||||
@@ -16,7 +17,6 @@ abstract class TestClass : Test {
|
||||
}
|
||||
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// MODULE: lib
|
||||
// !JVM_DEFAULT_MODE: disable
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
@@ -8,11 +8,11 @@ interface Test {
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FILE: 2.kt
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// MODULE: lib
|
||||
// !JVM_DEFAULT_MODE: disable
|
||||
// FILE: 1.kt
|
||||
|
||||
interface Test {
|
||||
@@ -9,11 +9,11 @@ interface Test {
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FILE: 2.kt
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// MODULE: lib
|
||||
// !JVM_DEFAULT_MODE: disable
|
||||
// FILE: 1.kt
|
||||
|
||||
interface Test {
|
||||
@@ -8,11 +8,11 @@ interface Test {
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FILE: 2.kt
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override val test: String
|
||||
get() = super.test
|
||||
}
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
// WITH_STDLIB
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
class A : BlockingDoubleChain
|
||||
|
||||
interface BlockingDoubleChain : BlockingBufferChain
|
||||
|
||||
interface BlockingBufferChain {
|
||||
suspend fun nextBuffer(): String = "OK"
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
it.getOrThrow()
|
||||
})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = "FAIL"
|
||||
builder {
|
||||
res = A().nextBuffer()
|
||||
}
|
||||
return res
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
// WITH_STDLIB
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Path {
|
||||
fun dispatch(s: String = "K") = "dispatch$s"
|
||||
fun Int.extension(s: String = "K") = "${this}extension$s"
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class RealPath(val x: Int) : Path
|
||||
|
||||
fun box(): String {
|
||||
val rp = RealPath(1)
|
||||
val res = "${rp.dispatch()};${rp.dispatch("KK")};" +
|
||||
with(rp) {
|
||||
"${1.extension()};${2.extension("KK")}"
|
||||
}
|
||||
if (res != "dispatchK;dispatchKK;1extensionK;2extensionKK") return res
|
||||
return "OK"
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
// WITH_STDLIB
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses, +GenericInlineClassParameter
|
||||
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Path {
|
||||
fun dispatch(s: String = "K") = "dispatch$s"
|
||||
fun Int.extension(s: String = "K") = "${this}extension$s"
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class RealPath<T: Int>(val x: T) : Path
|
||||
|
||||
fun box(): String {
|
||||
val rp = RealPath(1)
|
||||
val res = "${rp.dispatch()};${rp.dispatch("KK")};" +
|
||||
with(rp) {
|
||||
"${1.extension()};${2.extension("KK")}"
|
||||
}
|
||||
if (res != "dispatchK;dispatchKK;1extensionK;2extensionKK") return res
|
||||
return "OK"
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
// WITH_STDLIB
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Path {
|
||||
fun dispatch(maxDepth: Int = 42)
|
||||
fun Int.extension(maxDepth: Int = 42)
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class RealPath(val x: Int) : Path {
|
||||
override fun dispatch(maxDepth: Int) = Unit
|
||||
|
||||
fun childrenDispatch(recursively: Boolean): Unit =
|
||||
if (recursively) dispatch() else dispatch()
|
||||
|
||||
override fun Int.extension(maxDepth: Int) = Unit
|
||||
|
||||
fun Int.childrenExtension(recursively: Boolean): Unit =
|
||||
if (recursively) extension() else extension()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
RealPath(1)
|
||||
return "OK"
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
// WITH_STDLIB
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses, +GenericInlineClassParameter
|
||||
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Path {
|
||||
fun dispatch(maxDepth: Int = 42)
|
||||
fun Int.extension(maxDepth: Int = 42)
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class RealPath<T: Int>(val x: T) : Path {
|
||||
override fun dispatch(maxDepth: Int) = Unit
|
||||
|
||||
fun childrenDispatch(recursively: Boolean): Unit =
|
||||
if (recursively) dispatch() else dispatch()
|
||||
|
||||
override fun Int.extension(maxDepth: Int) = Unit
|
||||
|
||||
fun Int.childrenExtension(recursively: Boolean): Unit =
|
||||
if (recursively) extension() else extension()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
RealPath(1)
|
||||
return "OK"
|
||||
}
|
||||
Vendored
-50
@@ -1,50 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_STDLIB
|
||||
// JVM_TARGET: 1.8
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
// FILE: jvmDefaultEnable.kt
|
||||
|
||||
interface IFooBar {
|
||||
@JvmDefault fun foo() = "O"
|
||||
@JvmDefault fun bar() = "Failed"
|
||||
}
|
||||
|
||||
interface IFooBar2 : IFooBar
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class Test1(val k: String): IFooBar {
|
||||
override fun bar(): String = k
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class Test2(val k: String): IFooBar2 {
|
||||
override fun bar(): String = k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val k = Test1("K")
|
||||
val ik: IFooBar = k
|
||||
val k2 = Test2("K")
|
||||
val ik2: IFooBar = k2
|
||||
val ik3: IFooBar2 = k2
|
||||
|
||||
val test1 = k.foo() + k.bar()
|
||||
if (test1 != "OK") throw AssertionError("test1: $test1")
|
||||
|
||||
val test2 = ik.foo() + ik.bar()
|
||||
if (test2 != "OK") throw AssertionError("test2: $test2")
|
||||
|
||||
val test3 = k2.foo() + k2.bar()
|
||||
if (test3 != "OK") throw AssertionError("test3: $test3")
|
||||
|
||||
val test4 = ik2.foo() + ik2.bar()
|
||||
if (test4 != "OK") throw AssertionError("test4: $test4")
|
||||
|
||||
val test5 = ik3.foo() + ik3.bar()
|
||||
if (test5 != "OK") throw AssertionError("test5: $test5")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
-50
@@ -1,50 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_STDLIB
|
||||
// JVM_TARGET: 1.8
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses, +GenericInlineClassParameter
|
||||
|
||||
// FILE: jvmDefaultEnable.kt
|
||||
|
||||
interface IFooBar {
|
||||
@JvmDefault fun foo() = "O"
|
||||
@JvmDefault fun bar() = "Failed"
|
||||
}
|
||||
|
||||
interface IFooBar2 : IFooBar
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class Test1<T: String>(val k: T): IFooBar {
|
||||
override fun bar(): String = k
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class Test2<T: String>(val k: T): IFooBar2 {
|
||||
override fun bar(): String = k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val k = Test1("K")
|
||||
val ik: IFooBar = k
|
||||
val k2 = Test2("K")
|
||||
val ik2: IFooBar = k2
|
||||
val ik3: IFooBar2 = k2
|
||||
|
||||
val test1 = k.foo() + k.bar()
|
||||
if (test1 != "OK") throw AssertionError("test1: $test1")
|
||||
|
||||
val test2 = ik.foo() + ik.bar()
|
||||
if (test2 != "OK") throw AssertionError("test2: $test2")
|
||||
|
||||
val test3 = k2.foo() + k2.bar()
|
||||
if (test3 != "OK") throw AssertionError("test3: $test3")
|
||||
|
||||
val test4 = ik2.foo() + ik2.bar()
|
||||
if (test4 != "OK") throw AssertionError("test4: $test4")
|
||||
|
||||
val test5 = ik3.foo() + ik3.bar()
|
||||
if (test5 != "OK") throw AssertionError("test5: $test5")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_STDLIB
|
||||
// JVM_TARGET: 1.8
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
// FILE: jvmDefaultEnable.kt
|
||||
|
||||
interface IFooBar {
|
||||
@JvmDefault val foo get() = "O"
|
||||
@JvmDefault val bar get() = "Failed"
|
||||
}
|
||||
|
||||
interface IFooBar2 : IFooBar
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class Test1(override val bar: String): IFooBar
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class Test2(override val bar: String): IFooBar2
|
||||
|
||||
fun box(): String {
|
||||
val k = Test1("K")
|
||||
val ik: IFooBar = k
|
||||
val k2 = Test2("K")
|
||||
val ik2: IFooBar = k2
|
||||
val ik3: IFooBar2 = k2
|
||||
|
||||
val test1 = k.foo + k.bar
|
||||
if (test1 != "OK") throw AssertionError("test1: $test1")
|
||||
|
||||
val test2 = ik.foo + ik.bar
|
||||
if (test2 != "OK") throw AssertionError("test2: $test2")
|
||||
|
||||
val test3 = k2.foo + k2.bar
|
||||
if (test3 != "OK") throw AssertionError("test3: $test3")
|
||||
|
||||
val test4 = ik2.foo + ik2.bar
|
||||
if (test4 != "OK") throw AssertionError("test4: $test4")
|
||||
|
||||
val test5 = ik3.foo + ik3.bar
|
||||
if (test5 != "OK") throw AssertionError("test5: $test5")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_STDLIB
|
||||
// JVM_TARGET: 1.8
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses, +GenericInlineClassParameter
|
||||
|
||||
// FILE: jvmDefaultEnable.kt
|
||||
|
||||
interface IFooBar {
|
||||
@JvmDefault val foo get() = "O"
|
||||
@JvmDefault val bar get() = "Failed"
|
||||
}
|
||||
|
||||
interface IFooBar2 : IFooBar
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class Test1<T: String>(override val bar: T): IFooBar
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class Test2<T: String>(override val bar: T): IFooBar2
|
||||
|
||||
fun box(): String {
|
||||
val k = Test1("K")
|
||||
val ik: IFooBar = k
|
||||
val k2 = Test2("K")
|
||||
val ik2: IFooBar = k2
|
||||
val ik3: IFooBar2 = k2
|
||||
|
||||
val test1 = k.foo + k.bar
|
||||
if (test1 != "OK") throw AssertionError("test1: $test1")
|
||||
|
||||
val test2 = ik.foo + ik.bar
|
||||
if (test2 != "OK") throw AssertionError("test2: $test2")
|
||||
|
||||
val test3 = k2.foo + k2.bar
|
||||
if (test3 != "OK") throw AssertionError("test3: $test3")
|
||||
|
||||
val test4 = ik2.foo + ik2.bar
|
||||
if (test4 != "OK") throw AssertionError("test4: $test4")
|
||||
|
||||
val test5 = ik3.foo + ik3.bar
|
||||
if (test5 != "OK") throw AssertionError("test5: $test5")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
-52
@@ -1,52 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_STDLIB
|
||||
// JVM_TARGET: 1.8
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
// FILE: jvmDefaultEnable.kt
|
||||
|
||||
interface IFooBar {
|
||||
@JvmDefault val foo get() = "O"
|
||||
@JvmDefault val bar get() = "Failed"
|
||||
}
|
||||
|
||||
interface IFooBar2 : IFooBar
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class Test1(val k: String): IFooBar {
|
||||
override val bar: String
|
||||
get() = k
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class Test2(val k: String): IFooBar2 {
|
||||
override val bar: String
|
||||
get() = k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val k = Test1("K")
|
||||
val ik: IFooBar = k
|
||||
val k2 = Test2("K")
|
||||
val ik2: IFooBar = k2
|
||||
val ik3: IFooBar2 = k2
|
||||
|
||||
val test1 = k.foo + k.bar
|
||||
if (test1 != "OK") throw AssertionError("test1: $test1")
|
||||
|
||||
val test2 = ik.foo + ik.bar
|
||||
if (test2 != "OK") throw AssertionError("test2: $test2")
|
||||
|
||||
val test3 = k2.foo + k2.bar
|
||||
if (test3 != "OK") throw AssertionError("test3: $test3")
|
||||
|
||||
val test4 = ik2.foo + ik2.bar
|
||||
if (test4 != "OK") throw AssertionError("test4: $test4")
|
||||
|
||||
val test5 = ik3.foo + ik3.bar
|
||||
if (test5 != "OK") throw AssertionError("test5: $test5")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_STDLIB
|
||||
// JVM_TARGET: 1.8
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses, +GenericInlineClassParameter
|
||||
|
||||
// FILE: jvmDefaultEnable.kt
|
||||
|
||||
interface IFooBar {
|
||||
@JvmDefault val foo get() = "O"
|
||||
@JvmDefault val bar get() = "Failed"
|
||||
}
|
||||
|
||||
interface IFooBar2 : IFooBar
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class Test1<T: String>(val k: T): IFooBar {
|
||||
override val bar: String
|
||||
get() = k
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class Test2<T: String>(val k: T): IFooBar2 {
|
||||
override val bar: String
|
||||
get() = k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val k = Test1("K")
|
||||
val ik: IFooBar = k
|
||||
val k2 = Test2("K")
|
||||
val ik2: IFooBar = k2
|
||||
val ik3: IFooBar2 = k2
|
||||
|
||||
val test1 = k.foo + k.bar
|
||||
if (test1 != "OK") throw AssertionError("test1: $test1")
|
||||
|
||||
val test2 = ik.foo + ik.bar
|
||||
if (test2 != "OK") throw AssertionError("test2: $test2")
|
||||
|
||||
val test3 = k2.foo + k2.bar
|
||||
if (test3 != "OK") throw AssertionError("test3: $test3")
|
||||
|
||||
val test4 = ik2.foo + ik2.bar
|
||||
if (test4 != "OK") throw AssertionError("test4: $test4")
|
||||
|
||||
val test5 = ik3.foo + ik3.bar
|
||||
if (test5 != "OK") throw AssertionError("test5: $test5")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
var storage = "fail"
|
||||
|
||||
interface Test {
|
||||
|
||||
@JvmDefault
|
||||
private var foo: String
|
||||
get() = storage
|
||||
set(value) {
|
||||
storage = value
|
||||
}
|
||||
|
||||
@JvmDefault
|
||||
private fun bar(): String {
|
||||
return "K"
|
||||
}
|
||||
|
||||
@JvmDefault
|
||||
fun call(): String {
|
||||
return {
|
||||
foo = "O"
|
||||
foo + bar()
|
||||
}.let { it() }
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().call()
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
private val foo: String
|
||||
get() = "O"
|
||||
|
||||
@JvmDefault
|
||||
private fun bar(): String {
|
||||
return "K"
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun call(test: Test): String {
|
||||
return test.foo + test.bar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test
|
||||
|
||||
fun box(): String {
|
||||
return Test.call(TestClass())
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
private val foo: String
|
||||
get() = "O"
|
||||
|
||||
@JvmDefault
|
||||
private fun bar(): String {
|
||||
return "K"
|
||||
}
|
||||
|
||||
fun call(): String {
|
||||
return { foo + bar() }.let { it() }
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().call()
|
||||
}
|
||||
+1
-4
@@ -1,13 +1,10 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun foo(): String = "O"
|
||||
|
||||
@JvmDefault
|
||||
val bar: String
|
||||
get() = "K"
|
||||
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface IBase {
|
||||
@JvmDefault
|
||||
fun bar() = "OK"
|
||||
}
|
||||
|
||||
+3
-16
@@ -4,29 +4,16 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "O"
|
||||
}
|
||||
|
||||
fun delegatedTest(): String {
|
||||
return "fail"
|
||||
}
|
||||
fun test(): String = "Fail"
|
||||
}
|
||||
|
||||
class Delegate : Test {
|
||||
override fun test(): String {
|
||||
return "Fail"
|
||||
}
|
||||
|
||||
override fun delegatedTest(): String {
|
||||
return "K"
|
||||
}
|
||||
override fun test(): String = "OK"
|
||||
}
|
||||
|
||||
class TestClass(val foo: Test) : Test by foo
|
||||
|
||||
fun box(): String {
|
||||
val testClass = TestClass(Delegate())
|
||||
return testClass.test() + testClass.delegatedTest()
|
||||
return testClass.test()
|
||||
}
|
||||
|
||||
Vendored
+3
-13
@@ -4,26 +4,16 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
val test: String
|
||||
get() = "O"
|
||||
|
||||
val testDelegated: String
|
||||
get() = "fail"
|
||||
|
||||
val test: String get() = "Fail"
|
||||
}
|
||||
|
||||
class Delegate : Test {
|
||||
override val test: String
|
||||
get() = "fail"
|
||||
|
||||
override val testDelegated: String
|
||||
get() = "K"
|
||||
override val test: String get() = "OK"
|
||||
}
|
||||
|
||||
class TestClass(val foo: Test) : Test by foo
|
||||
|
||||
fun box(): String {
|
||||
val testClass = TestClass(Delegate())
|
||||
return testClass.test + testClass.testDelegated
|
||||
return testClass.test
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,11 +1,10 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// FULL_JDK
|
||||
// WITH_STDLIB
|
||||
|
||||
interface IFoo {
|
||||
@JvmDefault
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
+1
-3
@@ -1,4 +1,4 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: ANDROID
|
||||
// JVM_TARGET: 1.8
|
||||
@@ -6,7 +6,6 @@
|
||||
// FULL_JDK
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "Test"
|
||||
}
|
||||
@@ -18,7 +17,6 @@ open class TestClass : Test {
|
||||
|
||||
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return "Test2"
|
||||
}
|
||||
+4
-10
@@ -1,21 +1,15 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// IGNORE_INLINER: IR
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return inlineFun { "O" }
|
||||
return inlineFun { "OK" }
|
||||
}
|
||||
|
||||
fun testDefaultImpls(): String {
|
||||
return inlineFun { "K" }
|
||||
}
|
||||
|
||||
@JvmDefault
|
||||
private inline fun inlineFun(s: () -> String) = s()
|
||||
|
||||
}
|
||||
|
||||
class TestClass : Test {
|
||||
@@ -24,5 +18,5 @@ class TestClass : Test {
|
||||
|
||||
fun box(): String {
|
||||
val foo = TestClass()
|
||||
return foo.test() + foo.testDefaultImpls()
|
||||
return foo.test()
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// IGNORE_INLINER: IR
|
||||
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return inlineProp
|
||||
}
|
||||
|
||||
private inline val inlineProp: String
|
||||
get() = "OK"
|
||||
|
||||
}
|
||||
|
||||
class TestClass : Test {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String =
|
||||
TestClass().test()
|
||||
+1
-7
@@ -1,24 +1,18 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: ANDROID
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Z {
|
||||
|
||||
@JvmDefault
|
||||
private fun privateFun() = { "OK" }
|
||||
|
||||
@JvmDefault
|
||||
fun callPrivateFun() = privateFun()
|
||||
|
||||
@JvmDefault
|
||||
fun publicFun() = { "OK" }
|
||||
|
||||
@JvmDefault
|
||||
fun funWithDefaultArgs(s: () -> Unit = {}): () -> Unit
|
||||
|
||||
@JvmDefault
|
||||
val property: () -> Unit
|
||||
get() = {}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Z<T> {
|
||||
val value: T
|
||||
|
||||
val z: T
|
||||
get() = value
|
||||
}
|
||||
|
||||
@JvmDefaultWithoutCompatibility
|
||||
open class ZImpl : Z<String> {
|
||||
override val value: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
open class ZImpl2 : ZImpl() {
|
||||
override val z: String
|
||||
get() = super.z
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return ZImpl2().value
|
||||
}
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
@@ -13,7 +13,6 @@ public interface JBase extends Base {
|
||||
// FILE: main.kt
|
||||
|
||||
interface Base {
|
||||
@JvmDefault
|
||||
fun test(): String = "Base"
|
||||
}
|
||||
|
||||
+1
-3
@@ -1,15 +1,13 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface KCallable {
|
||||
@JvmDefault
|
||||
val returnType: String
|
||||
}
|
||||
|
||||
interface KCallableImpl : KCallable {
|
||||
@JvmDefault
|
||||
override val returnType: String
|
||||
get() = "OK"
|
||||
}
|
||||
+1
-3
@@ -1,15 +1,13 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface KCallable {
|
||||
@JvmDefault
|
||||
val returnType: String
|
||||
}
|
||||
|
||||
interface KCallableImpl : KCallable {
|
||||
@JvmDefault
|
||||
override val returnType: String
|
||||
get() = "OK"
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test<T> {
|
||||
@JvmDefault
|
||||
fun test(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test<String> {
|
||||
override fun test(p: String): String {
|
||||
return p + "K"
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> execute(t: Test<T>, p: T): T {
|
||||
return t.test(p)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return execute(TestClass(), "O")
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test<T> {
|
||||
@JvmDefault
|
||||
fun test(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2: Test<String> {
|
||||
@JvmDefault
|
||||
override fun test(p: String): String {
|
||||
return p + "K"
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test2 {
|
||||
}
|
||||
|
||||
fun <T> execute(t: Test<T>, p: T): T {
|
||||
return t.test(p)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return execute(TestClass(), "O")
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: ANDROID
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FULL_JDK
|
||||
|
||||
interface Test<T> {
|
||||
@JvmDefault
|
||||
fun test(p: T): T {
|
||||
return null!!
|
||||
}
|
||||
|
||||
fun foo(p: T): T {
|
||||
return null!!
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2: Test<String> {
|
||||
@JvmDefault
|
||||
override fun test(p: String): String {
|
||||
return p
|
||||
}
|
||||
|
||||
override fun foo(p: String): String {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test2
|
||||
|
||||
fun box(): String {
|
||||
checkNoMethod(Test2::class.java, "foo", Any::class.java)
|
||||
checkMethodExists(Test2::class.java, "test", Any::class.java)
|
||||
|
||||
checkNoMethod(TestClass::class.java, "test", Any::class.java)
|
||||
checkMethodExists(TestClass::class.java, "foo", String::class.java)
|
||||
checkMethodExists(TestClass::class.java, "foo", Any::class.java)
|
||||
|
||||
|
||||
val test2DefaultImpls = java.lang.Class.forName("Test2\$DefaultImpls")
|
||||
checkNoMethod(test2DefaultImpls, "test", Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "test", String::class.java)
|
||||
checkMethodExists(test2DefaultImpls, "foo", Test2::class.java, String::class.java)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun checkNoMethod(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return
|
||||
}
|
||||
throw AssertionError("fail: method $name was found in " + clazz)
|
||||
}
|
||||
|
||||
fun checkMethodExists(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
return
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
throw AssertionError("fail: method $name was not found in " + clazz, e)
|
||||
}
|
||||
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test<T> {
|
||||
@JvmDefault
|
||||
var test: T
|
||||
get() = null!!
|
||||
set(value) {
|
||||
null!!
|
||||
}
|
||||
}
|
||||
var result = "fail"
|
||||
|
||||
interface Test2 : Test<String> {
|
||||
@JvmDefault
|
||||
override var test: String
|
||||
get() = result
|
||||
set(value) {
|
||||
result = value
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test2
|
||||
|
||||
fun <T> execute(t: Test<T>, p: T): T {
|
||||
t.test = p
|
||||
return t.test
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return execute(TestClass(), "OK")
|
||||
}
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: ANDROID
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FULL_JDK
|
||||
|
||||
interface Test<T> {
|
||||
@JvmDefault
|
||||
var T.test: T
|
||||
get() = null!!
|
||||
set(value) {
|
||||
null!!
|
||||
}
|
||||
|
||||
var T.foo: T
|
||||
get() = null!!
|
||||
set(value) {
|
||||
null!!
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2 : Test<String> {
|
||||
@JvmDefault
|
||||
override var String.test: String
|
||||
get() = ""
|
||||
set(value) {}
|
||||
|
||||
override var String.foo: String
|
||||
get() = ""
|
||||
set(value) {}
|
||||
}
|
||||
|
||||
class TestClass : Test2
|
||||
|
||||
fun box(): String {
|
||||
checkMethodExists(Test2::class.java, "getTest", String::class.java)
|
||||
checkMethodExists(Test2::class.java, "getTest", Any::class.java)
|
||||
checkMethodExists(Test2::class.java, "setTest", Any::class.java, Any::class.java)
|
||||
checkMethodExists(Test2::class.java, "setTest", String::class.java, String::class.java)
|
||||
|
||||
checkNoMethod(Test2::class.java, "setFoo", Any::class.java, Any::class.java)
|
||||
|
||||
checkNoMethod(TestClass::class.java, "getTest", String::class.java)
|
||||
checkNoMethod(TestClass::class.java, "getTest", Any::class.java)
|
||||
checkNoMethod(TestClass::class.java, "setTest", Any::class.java, Any::class.java)
|
||||
checkNoMethod(TestClass::class.java, "setTest", String::class.java, String::class.java)
|
||||
|
||||
checkMethodExists(TestClass::class.java, "getFoo", String::class.java)
|
||||
checkMethodExists(TestClass::class.java, "getFoo", Any::class.java)
|
||||
checkMethodExists(TestClass::class.java, "setFoo", Any::class.java, Any::class.java)
|
||||
checkMethodExists(TestClass::class.java, "setFoo", String::class.java, String::class.java)
|
||||
|
||||
val test2DefaultImpls = java.lang.Class.forName("Test2\$DefaultImpls")
|
||||
checkNoMethod(test2DefaultImpls, "getTest", Test2::class.java, String::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "getTest", Test2::class.java, Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "setTest", Test2::class.java, Any::class.java, Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "setTest", Test2::class.java, String::class.java, String::class.java)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun checkNoMethod(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return
|
||||
}
|
||||
throw AssertionError("fail: method $name was found in " + clazz)
|
||||
}
|
||||
|
||||
fun checkMethodExists(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
return
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
throw AssertionError("fail: method $name was not found in " + clazz, e)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FULL_JDK
|
||||
|
||||
// FILE: Test.java
|
||||
|
||||
public interface Test<T> {
|
||||
default T test(T p) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: kotlin.kt
|
||||
|
||||
interface Test2: Test<String> {
|
||||
@JvmDefault
|
||||
override fun test(p: String): String {
|
||||
return p
|
||||
}
|
||||
|
||||
fun forDefaultImpls() {}
|
||||
}
|
||||
|
||||
class TestClass : Test2
|
||||
|
||||
fun box(): String {
|
||||
checkMethodExists(Test2::class.java, "test", String::class.java)
|
||||
checkMethodExists(Test2::class.java, "test", Any::class.java)
|
||||
|
||||
checkNoMethod(TestClass::class.java, "test", String::class.java)
|
||||
checkNoMethod(TestClass::class.java, "test", Any::class.java)
|
||||
|
||||
val test2DefaultImpls = java.lang.Class.forName("Test2\$DefaultImpls")
|
||||
checkNoMethod(test2DefaultImpls, "test", Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "test", String::class.java)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun checkNoMethod(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return
|
||||
}
|
||||
throw AssertionError("fail: method $name was found in " + clazz)
|
||||
}
|
||||
|
||||
fun checkMethodExists(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
return
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
throw AssertionError("fail: method $name was not found in " + clazz, e)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// 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
|
||||
|
||||
interface KInterface<T> {
|
||||
@JvmDefault
|
||||
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")
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// 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
|
||||
|
||||
interface KInterface<T> {
|
||||
@JvmDefault
|
||||
fun test2(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
interface KInterface2 : KInterface<String> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return Foo().test()
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// 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
|
||||
|
||||
interface KInterface<T> {
|
||||
@JvmDefault
|
||||
fun test2(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
interface KInterface2 : KInterface<String> {
|
||||
|
||||
}
|
||||
|
||||
interface KInterface3 : KInterface2 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return Foo().test()
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// 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
|
||||
|
||||
interface KInterface<T> {
|
||||
|
||||
val foo: T
|
||||
|
||||
@JvmDefault
|
||||
val bar: T
|
||||
get() = foo
|
||||
}
|
||||
|
||||
interface KInterface2 : KInterface<String> {
|
||||
@JvmDefault
|
||||
override val foo: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
|
||||
val result = Foo().test()
|
||||
if (result != "OK") return "fail 1: ${result}"
|
||||
|
||||
return Foo().bar
|
||||
|
||||
}
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// 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
|
||||
|
||||
interface KInterface<T> {
|
||||
|
||||
val foo: T
|
||||
|
||||
@JvmDefault
|
||||
val bar: T
|
||||
get() = foo
|
||||
}
|
||||
|
||||
interface KInterface2 : KInterface<String> {
|
||||
@JvmDefault
|
||||
override val foo: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return Foo().test()
|
||||
}
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// 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
|
||||
|
||||
interface KInterface<T> {
|
||||
|
||||
val foo: T
|
||||
|
||||
@JvmDefault
|
||||
val bar: T
|
||||
get() = foo
|
||||
}
|
||||
|
||||
interface KInterface2 : KInterface<String> {
|
||||
@JvmDefault
|
||||
override val foo: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
interface KInterface3 : KInterface2 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return Foo().test()
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FULL_JDK
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
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
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface A {
|
||||
@JvmDefault
|
||||
fun foo(x: String = "OK"): String {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = object : A {}
|
||||
return x.foo()
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface I {
|
||||
@Deprecated("message")
|
||||
@JvmDefault
|
||||
fun result() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String = object : I {}.result()
|
||||
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
interface I {
|
||||
@JvmDefault
|
||||
fun foo(x: String = "OK"): String = x
|
||||
}
|
||||
|
||||
interface J : I
|
||||
|
||||
object O : J
|
||||
|
||||
fun box(): String = O.foo()
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// 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
|
||||
|
||||
interface KInterface {
|
||||
@JvmDefault
|
||||
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
@@ -1,13 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
interface A {
|
||||
@JvmDefault
|
||||
fun String.foo(k: String) = "O" + k
|
||||
}
|
||||
|
||||
fun box(): String =
|
||||
object : A {
|
||||
fun box() = "FAIL".foo("K")
|
||||
}.box()
|
||||
@@ -1,27 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FILE: A.java
|
||||
|
||||
public interface A {
|
||||
default String foo() {
|
||||
return "fail";
|
||||
}
|
||||
}
|
||||
// FILE: B.java
|
||||
|
||||
public abstract class B implements A {}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
interface KDefault : A {
|
||||
@JvmDefault
|
||||
override fun foo() = "OK"
|
||||
}
|
||||
|
||||
class Problem : B(), KDefault
|
||||
|
||||
fun box(): String {
|
||||
return Problem().foo()
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// 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")
|
||||
@JvmDefault
|
||||
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
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// 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
|
||||
|
||||
interface KInterface {
|
||||
@JvmDefault
|
||||
fun test2(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val result = Foo().test()
|
||||
if (result != "OK") return "fail 1: ${result}"
|
||||
|
||||
return Foo().test2()
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Z {
|
||||
@JvmDefault
|
||||
fun test(s: String = "OK"): String {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
class Test: Z
|
||||
|
||||
fun box(): String {
|
||||
return Test().test()
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface A {
|
||||
@JvmDefault
|
||||
fun foo(x: String = "OK"): String {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = object : A {}
|
||||
return x.foo()
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "O"
|
||||
}
|
||||
|
||||
fun delegatedTest(): String {
|
||||
return "fail"
|
||||
}
|
||||
}
|
||||
|
||||
class Delegate : Test {
|
||||
override fun test(): String {
|
||||
return "Fail"
|
||||
}
|
||||
|
||||
override fun delegatedTest(): String {
|
||||
return "K"
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass(val foo: Test) : Test by foo
|
||||
|
||||
fun box(): String {
|
||||
val testClass = TestClass(Delegate())
|
||||
return testClass.test() + testClass.delegatedTest()
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
val test: String
|
||||
get() = "O"
|
||||
|
||||
val testDelegated: String
|
||||
get() = "fail"
|
||||
|
||||
}
|
||||
|
||||
class Delegate : Test {
|
||||
override val test: String
|
||||
get() = "fail"
|
||||
|
||||
override val testDelegated: String
|
||||
get() = "K"
|
||||
}
|
||||
|
||||
class TestClass(val foo: Test) : Test by foo
|
||||
|
||||
fun box(): String {
|
||||
val testClass = TestClass(Delegate())
|
||||
return testClass.test + testClass.testDelegated
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
interface I {
|
||||
@JvmDefault
|
||||
fun foo(x: String = "OK"): String = x
|
||||
}
|
||||
|
||||
interface J : I
|
||||
|
||||
object O : J
|
||||
|
||||
fun box(): String = O.foo()
|
||||
@@ -1,30 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return inlineProp
|
||||
}
|
||||
|
||||
fun testDefaultImpls(): String {
|
||||
return inlineProp
|
||||
}
|
||||
|
||||
@JvmDefault
|
||||
private inline val inlineProp: String
|
||||
get() = "OK"
|
||||
|
||||
}
|
||||
|
||||
class TestClass : Test {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val foo = TestClass()
|
||||
if (foo.test() != "OK") return "fail: ${foo.test()}"
|
||||
return foo.testDefaultImpls()
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Z<T> {
|
||||
@JvmDefault
|
||||
fun test(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
open class ZImpl : Z<String>
|
||||
|
||||
class ZImpl2 : ZImpl() {
|
||||
|
||||
override fun test(p: String): String {
|
||||
return super.test(p)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return ZImpl2().test("OK")
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Z<T> {
|
||||
@JvmDefault
|
||||
fun test(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
open class ZImpl : Z<String>
|
||||
|
||||
open class ZImpl2 : Z<String>, ZImpl()
|
||||
|
||||
class ZImpl3 : ZImpl2() {
|
||||
|
||||
override fun test(p: String): String {
|
||||
return super.test(p)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return ZImpl3().test("OK")
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// WITH_STDLIB
|
||||
// TARGET_BACKEND: JVM
|
||||
interface Base {
|
||||
@@ -8,8 +8,8 @@ interface Base {
|
||||
|
||||
interface SubA : Base
|
||||
|
||||
@JvmDefaultWithCompatibility
|
||||
interface SubB : Base {
|
||||
@JvmDefault
|
||||
override fun value(): String = "OK"
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FILE: A.java
|
||||
|
||||
public interface A {
|
||||
default String foo() {
|
||||
return "fail";
|
||||
}
|
||||
}
|
||||
// FILE: B.java
|
||||
|
||||
public abstract class B implements A {}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
interface KDefault : A {
|
||||
@JvmDefault
|
||||
override fun foo() = "OK"
|
||||
}
|
||||
|
||||
class Problem : B(), KDefault
|
||||
|
||||
fun box(): String {
|
||||
return Problem().foo()
|
||||
}
|
||||
+7
-4
@@ -1,12 +1,15 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun foo(): String = "O"
|
||||
|
||||
val bar: String
|
||||
get() = "K"
|
||||
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
return (::foo).let { it() } + (::bar).let { it() }
|
||||
}
|
||||
}
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface IBase {
|
||||
fun bar() = "OK"
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
@@ -18,7 +18,7 @@ fun box(): String {
|
||||
try {
|
||||
val defaultImpls = java.lang.Class.forName(Test::class.java.canonicalName + "\$DefaultImpls")
|
||||
} catch (e: ClassNotFoundException) {
|
||||
return "OK"
|
||||
return TestClass().test()
|
||||
}
|
||||
return "fail: DefaultImpls shouldn't be generated"
|
||||
}
|
||||
|
||||
+3
-16
@@ -4,29 +4,16 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "O"
|
||||
}
|
||||
|
||||
fun delegatedTest(): String {
|
||||
return "fail"
|
||||
}
|
||||
fun test(): String = "Fail"
|
||||
}
|
||||
|
||||
class Delegate : Test {
|
||||
override fun test(): String {
|
||||
return "Fail"
|
||||
}
|
||||
|
||||
override fun delegatedTest(): String {
|
||||
return "K"
|
||||
}
|
||||
override fun test(): String = "OK"
|
||||
}
|
||||
|
||||
class TestClass(val foo: Test) : Test by foo
|
||||
|
||||
fun box(): String {
|
||||
val testClass = TestClass(Delegate())
|
||||
return testClass.test() + testClass.delegatedTest()
|
||||
return testClass.test()
|
||||
}
|
||||
|
||||
+3
-13
@@ -4,26 +4,16 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
val test: String
|
||||
get() = "O"
|
||||
|
||||
val testDelegated: String
|
||||
get() = "fail"
|
||||
|
||||
val test: String get() = "Fail"
|
||||
}
|
||||
|
||||
class Delegate : Test {
|
||||
override val test: String
|
||||
get() = "fail"
|
||||
|
||||
override val testDelegated: String
|
||||
get() = "K"
|
||||
override val test: String get() = "OK"
|
||||
}
|
||||
|
||||
class TestClass(val foo: Test) : Test by foo
|
||||
|
||||
fun box(): String {
|
||||
val testClass = TestClass(Delegate())
|
||||
return testClass.test + testClass.testDelegated
|
||||
return testClass.test
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: ANDROID
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_REFLECT
|
||||
// FULL_JDK
|
||||
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return "Test"
|
||||
}
|
||||
}
|
||||
|
||||
open class TestClass : Test {
|
||||
|
||||
}
|
||||
|
||||
|
||||
interface Test2 : Test {
|
||||
override fun test(): String {
|
||||
return "Test2"
|
||||
}
|
||||
}
|
||||
|
||||
interface Test3 : Test2 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
class TestClass2 : TestClass(), Test3 {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val test = TestClass2().test()
|
||||
if (test != "Test2") return "fail 1: $test"
|
||||
checkNoMethod(TestClass::class.java, "test")
|
||||
checkNoMethod(Test3::class.java, "test")
|
||||
checkNoMethod(TestClass2::class.java, "test")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun checkNoMethod(clazz: Class<*>, name: String) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name)
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return
|
||||
}
|
||||
throw AssertionError("fail: method $name was found in " + clazz)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// IGNORE_INLINER: IR
|
||||
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return inlineFun { "OK" }
|
||||
}
|
||||
|
||||
private inline fun inlineFun(s: () -> String) = s()
|
||||
}
|
||||
|
||||
class TestClass : Test {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val foo = TestClass()
|
||||
return foo.test()
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// IGNORE_INLINER: IR
|
||||
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return inlineProp
|
||||
}
|
||||
|
||||
private inline val inlineProp: String
|
||||
get() = "OK"
|
||||
|
||||
}
|
||||
|
||||
class TestClass : Test {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String =
|
||||
TestClass().test()
|
||||
@@ -0,0 +1,56 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: ANDROID
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Z {
|
||||
private fun privateFun() = { "OK" }
|
||||
|
||||
fun callPrivateFun() = privateFun()
|
||||
|
||||
fun publicFun() = { "OK" }
|
||||
|
||||
fun funWithDefaultArgs(s: () -> Unit = {}): () -> Unit
|
||||
|
||||
val property: () -> Unit
|
||||
get() = {}
|
||||
|
||||
class Nested
|
||||
}
|
||||
|
||||
class Test : Z {
|
||||
override fun funWithDefaultArgs(s: () -> Unit): () -> Unit {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
val privateFun = Test().callPrivateFun()
|
||||
var enclosing = privateFun.javaClass.enclosingMethod!!
|
||||
if (enclosing.name != "privateFun") return "fail 1: ${enclosing.name}"
|
||||
if (enclosing.getDeclaringClass().simpleName != "Z") return "fail 2: ${enclosing.getDeclaringClass().simpleName}"
|
||||
|
||||
val publicFun = Test().publicFun()
|
||||
enclosing = publicFun.javaClass.enclosingMethod!!
|
||||
if (enclosing.name != "publicFun") return "fail 3: ${enclosing.name}"
|
||||
if (enclosing.getDeclaringClass().simpleName != "Z") return "fail 4: ${enclosing.getDeclaringClass().simpleName}"
|
||||
|
||||
val property = Test().property
|
||||
enclosing = property.javaClass.enclosingMethod!!
|
||||
if (enclosing.name != "getProperty") return "fail 4: ${enclosing.name}"
|
||||
if (enclosing.getDeclaringClass().simpleName != "Z") return "fail 5: ${enclosing.getDeclaringClass().simpleName}"
|
||||
|
||||
val defaultArgs = Test().funWithDefaultArgs()
|
||||
enclosing = defaultArgs.javaClass.enclosingMethod!!
|
||||
if (enclosing.name != "funWithDefaultArgs\$default") return "fail 6: ${enclosing.name}"
|
||||
if (enclosing.parameterTypes.size != 4) return "fail 7: not default method ${enclosing.name}"
|
||||
if (enclosing.getDeclaringClass().simpleName != "Z") return "fail 8: ${enclosing.getDeclaringClass().simpleName}"
|
||||
|
||||
val nested = Z.Nested::class.java
|
||||
val enclosingClass = nested.enclosingClass!!
|
||||
if (enclosingClass.name != "Z") return "fail 9: ${enclosingClass.name}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+1
-3
@@ -1,13 +1,11 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Z<T> {
|
||||
|
||||
val value: T
|
||||
|
||||
@JvmDefault
|
||||
val z: T
|
||||
get() = value
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface KCallable {
|
||||
val returnType: String
|
||||
}
|
||||
|
||||
interface KCallableImpl : KCallable {
|
||||
override val returnType: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
interface KCallableImpl2 : KCallableImpl
|
||||
|
||||
open class DescriptorBasedProperty : KCallableImpl
|
||||
open class KProperty1Impl : DescriptorBasedProperty(), KCallableImpl2
|
||||
open class KMutableProperty1Impl : KProperty1Impl(), KCallable
|
||||
|
||||
fun box(): String {
|
||||
return KMutableProperty1Impl().returnType
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface KCallable {
|
||||
val returnType: String
|
||||
}
|
||||
|
||||
interface KCallableImpl : KCallable {
|
||||
override val returnType: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
interface KProperty : KCallable
|
||||
interface KPropertyImpl : KProperty, KCallableImpl
|
||||
interface KMutableProperty : KProperty
|
||||
interface KProperty1 : KProperty
|
||||
interface KMutableProperty1 : KProperty1, KMutableProperty
|
||||
interface KMutablePropertyImpl : KPropertyImpl
|
||||
|
||||
open class DescriptorBasedProperty : KCallableImpl
|
||||
open class KProperty1Impl : DescriptorBasedProperty(), KProperty1, KPropertyImpl
|
||||
open class KMutableProperty1Impl : KProperty1Impl(), KMutableProperty1, KMutablePropertyImpl
|
||||
|
||||
fun box(): String {
|
||||
return KMutableProperty1Impl().returnType
|
||||
}
|
||||
Vendored
-26
@@ -1,26 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: ANDROID
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FULL_JDK
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test() {
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
TestClass::class.java.getDeclaredMethod("test")
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return "OK"
|
||||
}
|
||||
return "fail"
|
||||
}
|
||||
Vendored
-25
@@ -1,25 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FULL_JDK
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test() {
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2 : Test {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
Test2::class.java.getDeclaredMethod("test")
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return "OK"
|
||||
}
|
||||
return "fail"
|
||||
}
|
||||
Vendored
-29
@@ -1,29 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FULL_JDK
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test() {
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2 : Test {
|
||||
|
||||
}
|
||||
|
||||
interface Test3 : Test2 {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
Test3::class.java.getDeclaredMethod("test")
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return "OK"
|
||||
}
|
||||
return "fail"
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return privateFun() + privateProp
|
||||
}
|
||||
|
||||
@JvmDefault
|
||||
private fun privateFun(): String {
|
||||
return "O"
|
||||
}
|
||||
|
||||
@JvmDefault
|
||||
private val privateProp: String
|
||||
get() = "K"
|
||||
}
|
||||
|
||||
class TestImpl: Test
|
||||
|
||||
fun box(): String {
|
||||
return TestImpl().test()
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return privateFun() + privateProp
|
||||
}
|
||||
|
||||
private fun privateFun(): String {
|
||||
return "O"
|
||||
}
|
||||
|
||||
private val privateProp: String
|
||||
get() = "K"
|
||||
}
|
||||
|
||||
class TestImpl: Test
|
||||
|
||||
fun box(): String {
|
||||
return TestImpl().test()
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,6 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: ANDROID
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_REFLECT
|
||||
|
||||
@@ -8,7 +9,6 @@ annotation class Accessor(val value: String)
|
||||
|
||||
interface Z {
|
||||
@Property("OK")
|
||||
@JvmDefault
|
||||
val z: String
|
||||
@Accessor("OK")
|
||||
get() = "OK"
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Z {
|
||||
@JvmDefault
|
||||
val z: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
|
||||
class Test : Z
|
||||
|
||||
fun box() : String {
|
||||
return Test().z
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TestClass : Test2 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().test()
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_COROUTINES
|
||||
// WITH_STDLIB
|
||||
|
||||
import kotlin.coroutines.*
|
||||
import helpers.*
|
||||
|
||||
interface S {
|
||||
suspend fun foo()
|
||||
}
|
||||
|
||||
interface T : S {
|
||||
@JvmDefault
|
||||
override suspend fun foo() {
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar()
|
||||
}
|
||||
|
||||
object O : T {
|
||||
var result = ""
|
||||
|
||||
override fun bar() {
|
||||
result = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun builder(block: suspend () -> Unit) {
|
||||
block.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
builder { O.foo() }
|
||||
return O.result
|
||||
}
|
||||
Reference in New Issue
Block a user