toDelegateFor: JVM BE implementation
This commit is contained in:
committed by
Stanislav Erokhin
parent
e2b6d2d849
commit
97d5bbf1c2
+26
@@ -0,0 +1,26 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
var log: String = ""
|
||||
|
||||
inline fun <T> runLogged(entry: String, action: () -> T): T {
|
||||
log += entry
|
||||
return action()
|
||||
}
|
||||
|
||||
operator fun String.toDelegateFor(host: Any?, p: Any): String =
|
||||
runLogged("tdf($this);") { this }
|
||||
|
||||
operator fun String.getValue(receiver: Any?, p: Any): String =
|
||||
runLogged("get($this);") { this }
|
||||
|
||||
val testO by runLogged("O;") { "O" }
|
||||
val testK by runLogged("K;") { "K" }
|
||||
val testOK = runLogged("OK;") { testO + testK }
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("O;tdf(O);K;tdf(K);OK;get(O);get(K);", log)
|
||||
return testOK
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
var log: String = ""
|
||||
|
||||
inline fun <T> runLogged(entry: String, action: () -> T): T {
|
||||
log += entry
|
||||
return action()
|
||||
}
|
||||
|
||||
operator fun String.toDelegateFor(host: Any?, p: Any): String =
|
||||
runLogged("tdf($this);") { this }
|
||||
|
||||
operator fun String.getValue(receiver: Any?, p: Any): String =
|
||||
runLogged("get($this);") { this }
|
||||
|
||||
class Test {
|
||||
val testO by runLogged("O;") { "O" }
|
||||
val testK by runLogged("K;") { "K" }
|
||||
val testOK = runLogged("OK;") { testO + testK }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("", log)
|
||||
val test = Test()
|
||||
assertEquals("O;tdf(O);K;tdf(K);OK;get(O);get(K);", log)
|
||||
return test.testOK
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
var log: String = ""
|
||||
|
||||
inline fun <T> runLogged(entry: String, action: () -> T): T {
|
||||
log += entry
|
||||
return action()
|
||||
}
|
||||
|
||||
inline operator fun String.toDelegateFor(host: Any?, p: Any): String =
|
||||
runLogged("tdf($this);") { this }
|
||||
|
||||
operator fun String.getValue(receiver: Any?, p: Any): String =
|
||||
runLogged("get($this);") { this }
|
||||
|
||||
val testO by runLogged("O;") { "O" }
|
||||
val testK by runLogged("K;") { "K" }
|
||||
val testOK = runLogged("OK;") { testO + testK }
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("O;tdf(O);K;tdf(K);OK;get(O);get(K);", log)
|
||||
return testOK
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
var log: String = ""
|
||||
|
||||
inline fun <T> runLogged(entry: String, action: () -> T): T {
|
||||
log += entry
|
||||
return action()
|
||||
}
|
||||
|
||||
operator fun String.toDelegateFor(host: Any?, p: Any): String =
|
||||
runLogged("tdf($this);") { this }
|
||||
|
||||
operator fun String.getValue(receiver: Any?, p: Any): String =
|
||||
runLogged("get($this);") { this }
|
||||
|
||||
object Test {
|
||||
fun foo() {}
|
||||
@JvmStatic val testO by runLogged("O;") { "O" }
|
||||
@JvmStatic val testK by runLogged("K;") { "K" }
|
||||
@JvmStatic val testOK = runLogged("OK;") { testO + testK }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("", log)
|
||||
Test.foo()
|
||||
assertEquals("O;tdf(O);K;tdf(K);OK;get(O);get(K);", log)
|
||||
return Test.testOK
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
object Host {
|
||||
class StringDelegate(val s: String) {
|
||||
operator fun getValue(receiver: String, p: Any) = receiver + s
|
||||
}
|
||||
|
||||
operator fun String.toDelegateFor(host: Any?, p: Any) = StringDelegate(this)
|
||||
|
||||
val String.plusK by "K"
|
||||
|
||||
val ok = "O".plusK
|
||||
}
|
||||
|
||||
fun box(): String = Host.ok
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
public final class EvaluationOrderKt {
|
||||
private synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
|
||||
private static @org.jetbrains.annotations.NotNull field log: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field testK$delegate: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field testO$delegate: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field testOK: java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getLog(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getTestK(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getTestO(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getTestOK(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.NotNull p2: java.lang.Object): java.lang.String
|
||||
public final static method runLogged(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.NotNull p1: kotlin.jvm.functions.Function0): java.lang.Object
|
||||
public final static method setLog(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final static @org.jetbrains.annotations.NotNull method toDelegateFor(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.NotNull p2: java.lang.Object): java.lang.String
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
public final class InClassKt {
|
||||
private static @org.jetbrains.annotations.NotNull field log: java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getLog(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.NotNull p2: java.lang.Object): java.lang.String
|
||||
public final static method runLogged(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.NotNull p1: kotlin.jvm.functions.Function0): java.lang.Object
|
||||
public final static method setLog(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final static @org.jetbrains.annotations.NotNull method toDelegateFor(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.NotNull p2: java.lang.Object): java.lang.String
|
||||
}
|
||||
|
||||
|
||||
public final class Test {
|
||||
private synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
|
||||
private final @org.jetbrains.annotations.NotNull field testK$delegate: java.lang.String
|
||||
private final @org.jetbrains.annotations.NotNull field testO$delegate: java.lang.String
|
||||
private final @org.jetbrains.annotations.NotNull field testOK: java.lang.String
|
||||
public method <init>(): void
|
||||
public final @org.jetbrains.annotations.NotNull method getTestK(): java.lang.String
|
||||
public final @org.jetbrains.annotations.NotNull method getTestO(): java.lang.String
|
||||
public final @org.jetbrains.annotations.NotNull method getTestOK(): java.lang.String
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
public final class InlineToDelegateForKt {
|
||||
private synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
|
||||
private static @org.jetbrains.annotations.NotNull field log: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field testK$delegate: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field testO$delegate: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field testOK: java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getLog(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getTestK(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getTestO(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getTestOK(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.NotNull p2: java.lang.Object): java.lang.String
|
||||
public final static method runLogged(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.NotNull p1: kotlin.jvm.functions.Function0): java.lang.Object
|
||||
public final static method setLog(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final static @org.jetbrains.annotations.NotNull method toDelegateFor(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.NotNull p2: java.lang.Object): java.lang.String
|
||||
}
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
public final class JvmStaticInObjectKt {
|
||||
private static @org.jetbrains.annotations.NotNull field log: java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getLog(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.NotNull p2: java.lang.Object): java.lang.String
|
||||
public final static method runLogged(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.NotNull p1: kotlin.jvm.functions.Function0): java.lang.Object
|
||||
public final static method setLog(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final static @org.jetbrains.annotations.NotNull method toDelegateFor(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.NotNull p2: java.lang.Object): java.lang.String
|
||||
}
|
||||
|
||||
|
||||
public final class Test {
|
||||
private synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
|
||||
public final static field INSTANCE: Test
|
||||
private final static @org.jetbrains.annotations.NotNull field testK$delegate: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field testO$delegate: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field testOK: java.lang.String
|
||||
private method <init>(): void
|
||||
public final method foo(): void
|
||||
public final static @org.jetbrains.annotations.NotNull method getTestK(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getTestO(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method getTestOK(): java.lang.String
|
||||
private synthetic deprecated static @kotlin.jvm.JvmStatic method testK$annotations(): void
|
||||
private synthetic deprecated static @kotlin.jvm.JvmStatic method testO$annotations(): void
|
||||
private synthetic deprecated static @kotlin.jvm.JvmStatic method testOK$annotations(): void
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
public final class Host {
|
||||
private synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
|
||||
public final static field INSTANCE: Host
|
||||
private final static @org.jetbrains.annotations.NotNull field ok: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field plusK$delegate: Host.StringDelegate
|
||||
inner class Host/StringDelegate
|
||||
private method <init>(): void
|
||||
public final @org.jetbrains.annotations.NotNull method getOk(): java.lang.String
|
||||
public final @org.jetbrains.annotations.NotNull method getPlusK(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String
|
||||
public final @org.jetbrains.annotations.NotNull method toDelegateFor(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.NotNull p2: java.lang.Object): Host.StringDelegate
|
||||
}
|
||||
|
||||
|
||||
public final static class Host/StringDelegate {
|
||||
private final @org.jetbrains.annotations.NotNull field s: java.lang.String
|
||||
inner class Host/StringDelegate
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
|
||||
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.NotNull p1: java.lang.Object): java.lang.String
|
||||
}
|
||||
|
||||
|
||||
public final class MemberExtensionKt {
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
Reference in New Issue
Block a user