JS: bound callable references (KT-13573).
This commit is contained in:
-3
@@ -1,6 +1,3 @@
|
||||
// TODO investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
class A {
|
||||
companion object {
|
||||
fun ok() = "OK"
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
enum class E {
|
||||
A, B;
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
inline fun foo(x: () -> String) = x()
|
||||
|
||||
fun String.id() = this
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
inline fun go(f: () -> String) = f()
|
||||
|
||||
fun String.id(): String = this
|
||||
|
||||
+1
-4
@@ -1,8 +1,5 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// Enable when callable references to builtin members is supported
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// See KT-12995
|
||||
|
||||
fun box(): String {
|
||||
var state = 0
|
||||
val name = (state++)::toString.name
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// Enable when callable references to builtin members is supported
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun <T> get(t: T): () -> String {
|
||||
return t::toString
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
class A(var v: Int) {
|
||||
fun f(x: Int) = x * v
|
||||
}
|
||||
|
||||
fun A.g(x: Int) = x * f(x);
|
||||
|
||||
var A.w: Int
|
||||
get() = 1000 * v
|
||||
set(c: Int) {
|
||||
v = c + 10
|
||||
}
|
||||
|
||||
object F {
|
||||
var u = 0
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A(5)
|
||||
|
||||
val av = a::v
|
||||
if (av() != 5) return "fail1: ${av()}"
|
||||
if (av.get() != 5) return "fail2: ${av.get()}"
|
||||
av.set(7)
|
||||
if (a.v != 7) return "fail3: ${a.v}"
|
||||
|
||||
val af = a::f
|
||||
if (af(10) != 70) return "fail4: ${af(10)}"
|
||||
|
||||
val ag = a::g
|
||||
if (ag(10) != 700) return "fail5: ${ag(10)}"
|
||||
|
||||
val aw = a::w
|
||||
if (aw() != 7000) return "fail6: ${aw()}"
|
||||
if (aw.get() != 7000) return "fail7: ${aw.get()}"
|
||||
aw.set(5)
|
||||
if (a.v != 15) return "fail8: ${a.v}"
|
||||
|
||||
val fu = F::u
|
||||
if (fu() != 0) return "fail9: ${fu()}"
|
||||
if (fu.get() != 0) return "fail10: ${fu.get()}"
|
||||
fu.set(8)
|
||||
if (F.u != 8) return "fail11: ${F.u}"
|
||||
|
||||
val x = 100
|
||||
|
||||
fun A.lf() = v * x;
|
||||
val alf = a::lf
|
||||
if (alf() != 1500) return "fail9: ${alf()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,8 +1,3 @@
|
||||
// TODO: investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// See https://youtrack.jetbrains.com/issue/KT-14939
|
||||
|
||||
val String?.ok: String
|
||||
get() = "OK"
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// TODO investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
object Singleton {
|
||||
fun ok() = "OK"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// Enable when callable references to builtin members is supported
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun box(): String {
|
||||
val f = "KOTLIN"::get
|
||||
return "${f(1)}${f(0)}"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// Enable when callable references to builtin members are supported.
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun box(): String {
|
||||
|
||||
+1
-3
@@ -1,6 +1,4 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// FILE: A.java
|
||||
|
||||
|
||||
Reference in New Issue
Block a user