tests: Update external tests (1.1.2-dev-393)
This commit is contained in:
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
abstract class A {
|
||||
abstract fun foo(): String
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
override fun foo() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String = (A::foo)(B())
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
fun box(): String {
|
||||
if ((Boolean::not)(true) != false) return "Fail 1"
|
||||
if ((Boolean::not)(false) != true) return "Fail 2"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
class A {
|
||||
fun foo(k: Int) = k
|
||||
|
||||
fun result() = (A::foo)(this, 111)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = A().result()
|
||||
if (result != 111) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
fun o() = 111
|
||||
fun k(k: Int) = k
|
||||
}
|
||||
|
||||
fun A.foo() = (A::o)(this) + (A::k)(this, 222)
|
||||
|
||||
fun box(): String {
|
||||
val result = A().foo()
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class A {
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
return x(A())
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class A {
|
||||
fun foo(result: String) = result
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
return x(A(), "OK")
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
var result = "Fail"
|
||||
|
||||
fun foo() {
|
||||
result = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
val x = A::foo
|
||||
x(a)
|
||||
return a.result
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
var result = "Fail"
|
||||
|
||||
fun foo(newResult: String) {
|
||||
result = newResult
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
val x = A::foo
|
||||
x(a, "OK")
|
||||
return a.result
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class A {
|
||||
var result = "OK"
|
||||
}
|
||||
|
||||
fun box() = (::A)().result
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class A(val result: String)
|
||||
|
||||
fun box() = (::A)("OK").result
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
enum class E {
|
||||
ENTRY
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val f = E::valueOf
|
||||
val result = f("ENTRY")
|
||||
return if (result == E.ENTRY) "OK" else "Fail $result"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class A
|
||||
|
||||
fun box() = if ((A::equals)(A(), A())) "Fail" else "OK"
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class A {
|
||||
fun result() = (A::foo)(this, "OK")
|
||||
}
|
||||
|
||||
fun A.foo(x: String) = x
|
||||
|
||||
fun box() = A().result()
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
class A
|
||||
|
||||
fun A.foo() = (A::bar)(this, "OK")
|
||||
|
||||
fun A.bar(x: String) = x
|
||||
|
||||
fun box() = A().foo()
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class A
|
||||
|
||||
fun A.foo() = "OK"
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
return x(A())
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class A
|
||||
|
||||
fun A.foo(result: String) = result
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
return x(A(), "OK")
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
var result = "Fail"
|
||||
}
|
||||
|
||||
fun A.foo() {
|
||||
result = "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
val x = A::foo
|
||||
x(a)
|
||||
return a.result
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
var result = "Fail"
|
||||
}
|
||||
|
||||
fun A.foo(newResult: String) {
|
||||
result = newResult
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
val x = A::foo
|
||||
x(a, "OK")
|
||||
return a.result
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun <T, R> foo(x: T): R = TODO()
|
||||
fun <T> fooReturnInt(x: T): Int = 1
|
||||
|
||||
inline fun <reified T, reified R> check(x: T, y: R, f: (T) -> R, tType: String, rType: String) {
|
||||
assertEquals(tType, T::class.simpleName)
|
||||
assertEquals(rType, R::class.simpleName)
|
||||
}
|
||||
|
||||
inline fun <reified T, reified R> check(f: (T) -> R, g: (T) -> R, tType: String, rType: String) {
|
||||
assertEquals(tType, T::class.simpleName)
|
||||
assertEquals(rType, R::class.simpleName)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
check("", 1, ::foo, "String", "Int")
|
||||
check("", 1, ::fooReturnInt, "String", "Int")
|
||||
check("", "", ::fooReturnInt, "String", "Any")
|
||||
|
||||
check(Int::toString, ::foo, "Int", "String")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun <T, R> foo(x: T): R = TODO()
|
||||
|
||||
inline fun <reified T, reified R> bar(x: T, y: R, f: (T) -> R, tType: String, rType: String): Pair<T, R?> {
|
||||
assertEquals(tType, T::class.simpleName)
|
||||
assertEquals(rType, R::class.simpleName)
|
||||
return Pair(x, y)
|
||||
}
|
||||
|
||||
data class Pair<A, B>(val a: A, val b: B)
|
||||
|
||||
fun box(): String {
|
||||
bar(1, "", ::foo, "Int", "String")
|
||||
|
||||
val s1: Pair<Int, String?> = bar(1, "", ::foo, "Int", "String")
|
||||
val (a: Int, b: String?) = bar(1, "", ::foo, "Int", "String")
|
||||
|
||||
val ns: String? = null
|
||||
bar(ns, ns, ::foo, "String", "String")
|
||||
|
||||
val s2: Pair<Int?, String?> = bar(null, null, ::foo, "Int", "String")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun foo(x: Int?) {}
|
||||
fun foo(y: String?) {}
|
||||
fun foo(z: Boolean) {}
|
||||
|
||||
inline fun <reified T> bar(f: (T) -> Unit, tType: String): T? {
|
||||
assertEquals(tType, T::class.simpleName)
|
||||
return null
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a1: Int? = bar(::foo, "Int")
|
||||
val a2: String? = bar(::foo, "String")
|
||||
val a3: Boolean? = bar<Boolean>(::foo, "Boolean")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class A<T>(val t: T) {
|
||||
fun foo(): T = t
|
||||
}
|
||||
|
||||
fun box() = (A<String>::foo)(A("OK"))
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Wrapper<T>(val value: T)
|
||||
|
||||
fun box(): String {
|
||||
val ls = listOf("OK").map(::Wrapper)
|
||||
return ls[0].value
|
||||
}
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.jvm.internal.FunctionBase
|
||||
|
||||
fun test(f: Function<*>, arity: Int) {
|
||||
assertEquals(arity, (f as FunctionBase).getArity())
|
||||
}
|
||||
|
||||
fun foo(s: String, i: Int) {}
|
||||
class A {
|
||||
fun bar(s: String, i: Int) {}
|
||||
}
|
||||
fun Double.baz(s: String, i: Int) {}
|
||||
|
||||
fun box(): String {
|
||||
test(::foo, 2)
|
||||
test(A::bar, 3)
|
||||
test(Double::baz, 3)
|
||||
|
||||
test(::box, 0)
|
||||
|
||||
fun local(x: Int) {}
|
||||
test(::local, 1)
|
||||
|
||||
test(fun(s: String) = s, 1)
|
||||
test(fun(){}, 0)
|
||||
test({}, 0)
|
||||
test({x: Int -> x}, 1)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
inner class Inner {
|
||||
val o = 111
|
||||
val k = 222
|
||||
}
|
||||
|
||||
fun result() = (A::Inner)(this).o + (A::Inner)(this).k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = A().result()
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
inner class Inner {
|
||||
val o = 111
|
||||
val k = 222
|
||||
}
|
||||
}
|
||||
|
||||
fun A.foo() = (A::Inner)(this).o + (A::Inner)(this).k
|
||||
|
||||
fun box(): String {
|
||||
val result = A().foo()
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
inner class Inner {
|
||||
val o = 111
|
||||
val k = 222
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = (A::Inner)((::A)()).o + (A::Inner)(A()).k
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class A {
|
||||
inner class Inner(val result: Int)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = (A::Inner)((::A)(), 111).result + (A::Inner)(A(), 222).result
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// KT-5123
|
||||
|
||||
import java.util.Collections
|
||||
import java.util.ArrayList
|
||||
|
||||
fun box(): String {
|
||||
val numbers = ArrayList<Int>()
|
||||
numbers.add(1)
|
||||
numbers.add(2)
|
||||
numbers.add(3)
|
||||
(Collections::rotate)(numbers, 1)
|
||||
return if ("$numbers" == "[3, 1, 2]") "OK" else "Fail $numbers"
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class Outer {
|
||||
val result = "OK"
|
||||
|
||||
inner class Inner {
|
||||
fun foo() = result
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val f = Outer.Inner::foo
|
||||
return f(Outer().Inner())
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun box(): String {
|
||||
class Local {
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
val ref = Local::foo
|
||||
return ref(Local())
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
fun box(): String {
|
||||
var result = "Fail"
|
||||
|
||||
fun changeToOK() { result = "OK" }
|
||||
|
||||
val ok = ::changeToOK
|
||||
ok()
|
||||
return result
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fun box(): String {
|
||||
class A {
|
||||
val result = "OK"
|
||||
}
|
||||
|
||||
return (::A)().result
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
class A {
|
||||
var result: String = "Fail";
|
||||
init {
|
||||
result = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
return (::A)().result
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
interface Named {
|
||||
val name: String
|
||||
}
|
||||
|
||||
enum class E : Named {
|
||||
OK
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return E.OK.name
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class A
|
||||
|
||||
fun box(): String {
|
||||
fun A.foo() = "OK"
|
||||
return (A::foo)(A())
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
fun box(): String {
|
||||
class A
|
||||
fun A.foo() = "OK"
|
||||
return (A::foo)((::A)())
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
fun box(): String {
|
||||
fun Int.is42With(that: Int) = this + 2 * that == 42
|
||||
return if ((Int::is42With)(16, 13)) "OK" else "Fail"
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
class A
|
||||
|
||||
fun box(): String {
|
||||
var result = "Fail"
|
||||
|
||||
fun A.ext() { result = "OK" }
|
||||
|
||||
val f = A::ext
|
||||
f(A())
|
||||
return result
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
fun box(): String {
|
||||
class Id<T> {
|
||||
fun invoke(t: T) = t
|
||||
}
|
||||
|
||||
val ref = Id<String>::invoke
|
||||
return ref(Id<String>(), "OK")
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
fun box(): String {
|
||||
val result = "OK"
|
||||
|
||||
class Local {
|
||||
fun foo() = result
|
||||
}
|
||||
|
||||
val member = Local::foo
|
||||
val instance = Local()
|
||||
return member(instance)
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
fun box(): String {
|
||||
fun OK() {}
|
||||
|
||||
return ::OK.name
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
fun foo(): String {
|
||||
fun bar() = "OK"
|
||||
val ref = ::bar
|
||||
return ref()
|
||||
}
|
||||
|
||||
val ref = ::foo
|
||||
return ref()
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
fun foo(until: Int): String {
|
||||
fun bar(x: Int): String =
|
||||
if (x == until) "OK" else bar(x + 1)
|
||||
return (::bar)(0)
|
||||
}
|
||||
|
||||
fun box() = foo(10)
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun box(): String {
|
||||
fun foo() = "OK"
|
||||
return (::foo)()
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
fun box(): String {
|
||||
val result = "OK"
|
||||
|
||||
fun foo() = result
|
||||
|
||||
return (::foo)()
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
fun box(): String {
|
||||
fun foo(s: String) = s
|
||||
return (::foo)("OK")
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
var state = 23
|
||||
|
||||
fun box(): String {
|
||||
fun incrementState(inc: Int) {
|
||||
state += inc
|
||||
}
|
||||
|
||||
val inc = ::incrementState
|
||||
inc(12)
|
||||
inc(-5)
|
||||
inc(27)
|
||||
inc(-15)
|
||||
|
||||
return if (state == 42) "OK" else "Fail $state"
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
class Nested {
|
||||
val o = 111
|
||||
val k = 222
|
||||
}
|
||||
|
||||
fun result() = (::Nested)().o + (A::Nested)().k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = A().result()
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class A {
|
||||
class Nested {
|
||||
val result = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = (A::Nested)().result
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class A {
|
||||
class Nested(val result: String)
|
||||
}
|
||||
|
||||
fun box() = (A::Nested)("OK").result
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
private fun <T> upcast(value: T): T = value
|
||||
|
||||
fun box(): String {
|
||||
upcast<(Int)->ByteArray>(::ByteArray)(10)
|
||||
upcast<(Int)->IntArray>(::IntArray)(10)
|
||||
upcast<(Int)->ShortArray>(::ShortArray)(10)
|
||||
upcast<(Int)->LongArray>(::LongArray)(10)
|
||||
upcast<(Int)->DoubleArray>(::DoubleArray)(10)
|
||||
upcast<(Int)->FloatArray>(::FloatArray)(10)
|
||||
upcast<(Int)->BooleanArray>(::BooleanArray)(10)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
fun foo(): String = "foo1"
|
||||
fun foo(i: Int): String = "foo2"
|
||||
|
||||
val f1: () -> String = ::foo
|
||||
val f2: (Int) -> String = ::foo
|
||||
|
||||
fun foo1() {}
|
||||
fun foo2(i: Int) {}
|
||||
|
||||
fun bar(f: () -> Unit): String = "bar1"
|
||||
fun bar(f: (Int) -> Unit): String = "bar2"
|
||||
|
||||
fun box(): String {
|
||||
val x1 = f1()
|
||||
if (x1 != "foo1") return "Fail 1: $x1"
|
||||
|
||||
val x2 = f2(0)
|
||||
if (x2 != "foo2") return "Fail 2: $x2"
|
||||
|
||||
val y1 = bar(::foo1)
|
||||
if (y1 != "bar1") return "Fail 3: $y1"
|
||||
|
||||
val y2 = bar(::foo2)
|
||||
if (y2 != "bar2") return "Fail 4: $y2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A {
|
||||
val x = 1
|
||||
fun x(): String = "OK"
|
||||
}
|
||||
|
||||
val f1: KProperty1<A, Int> = A::x
|
||||
val f2: (A) -> String = A::x
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
|
||||
val x1 = f1.get(a)
|
||||
if (x1 != 1) return "Fail 1: $x1"
|
||||
|
||||
return f2(a)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class A {
|
||||
private fun foo() = "OK"
|
||||
|
||||
fun bar() = (A::foo)(this)
|
||||
}
|
||||
|
||||
fun box() = A().bar()
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun sort(list: MutableList<String>, comparator: (String, String) -> Int) {
|
||||
list.sortWith(Comparator(comparator))
|
||||
}
|
||||
|
||||
fun compare(s1: String, s2: String) = s1.compareTo(s2)
|
||||
|
||||
fun box(): String {
|
||||
val l = mutableListOf("d", "b", "c", "e", "a")
|
||||
sort(l, ::compare)
|
||||
if (l != listOf("a", "b", "c", "d", "e")) return "Fail: $l"
|
||||
return "OK"
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
fun baz(i: Int) = i
|
||||
fun <T> bar(x: T): T = x
|
||||
|
||||
fun nullableFun(): ((Int) -> Int)? = null
|
||||
|
||||
fun box(): String {
|
||||
val x1: (Int) -> Int = bar(if (true) ::baz else ::baz)
|
||||
val x2: (Int) -> Int = bar(nullableFun() ?: ::baz)
|
||||
val x3: (Int) -> Int = bar(::baz ?: ::baz)
|
||||
|
||||
val i = 0
|
||||
val x4: (Int) -> Int = bar(when (i) {
|
||||
10 -> ::baz
|
||||
20 -> ::baz
|
||||
else -> ::baz
|
||||
})
|
||||
|
||||
val x5: (Int) -> Int = bar(::baz!!)
|
||||
|
||||
if (x1(1) != 1) return "fail 1"
|
||||
if (x2(1) != 1) return "fail 2"
|
||||
if (x3(1) != 1) return "fail 3"
|
||||
if (x4(1) != 1) return "fail 4"
|
||||
if (x5(1) != 1) return "fail 5"
|
||||
|
||||
if ((if (true) ::baz else ::baz)(1) != 1) return "fail 6"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fun foo(o: Int, k: Int) = o + k
|
||||
|
||||
class A {
|
||||
fun bar() = (::foo)(111, 222)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = A().bar()
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
fun foo(o: Int, k: Int) = o + k
|
||||
|
||||
class A
|
||||
|
||||
fun A.bar() = (::foo)(111, 222)
|
||||
|
||||
fun box(): String {
|
||||
val result = A().bar()
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun foo() = "OK"
|
||||
|
||||
fun box(): String {
|
||||
val x = ::foo
|
||||
return x()
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun foo(x: String) = x
|
||||
|
||||
fun box(): String {
|
||||
val x = ::foo
|
||||
return x("OK")
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
var result = "Fail"
|
||||
|
||||
fun foo() {
|
||||
result = "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = ::foo
|
||||
x()
|
||||
return result
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
var result = "Fail"
|
||||
|
||||
fun foo(newResult: String) {
|
||||
result = newResult
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = ::foo
|
||||
x("OK")
|
||||
return result
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
interface T {
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
class B : T {
|
||||
inner class C {
|
||||
fun bar() = (T::foo)(this@B)
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = B().C().bar()
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
interface A {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
class B : A {
|
||||
override fun foo() = "OK"
|
||||
}
|
||||
|
||||
fun box() = (A::foo)(B())
|
||||
Reference in New Issue
Block a user