KT-23397 Optimize out field for property delegate when it's safe (JVM)

This commit is contained in:
Pavel Mikhailovskii
2022-06-03 16:54:12 +02:00
committed by teamcity
parent 9ee0268197
commit 65b2cee913
83 changed files with 3015 additions and 19 deletions
@@ -0,0 +1,8 @@
// CHECK_BYTECODE_LISTING
operator fun Any?.getValue(thisRef: Any?, property: Any?) =
if (this == 1 && thisRef == null) "OK" else "Failed"
val s: String by 1
fun box() = s
@@ -0,0 +1,10 @@
@kotlin.Metadata
public final class DelegateToConstKt {
// source: 'delegateToConst.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static field s$delegate: int
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,10 @@
// CHECK_BYTECODE_LISTING
operator fun Any?.getValue(thisRef: Any?, property: Any?) =
if (this == a && thisRef == null) "OK" else "Failed"
const val a = "TEXT"
val s: String by a
fun box(): String = s
@@ -0,0 +1,11 @@
@kotlin.Metadata
public final class DelegateToConstPropertyKt {
// source: 'delegateToConstProperty.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
public final static @org.jetbrains.annotations.NotNull field a: java.lang.String
private final static @org.jetbrains.annotations.NotNull field s$delegate: java.lang.String
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,11 @@
@kotlin.Metadata
public final class DelegateToConstPropertyKt {
// source: 'delegateToConstProperty.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
public final static @org.jetbrains.annotations.NotNull field a: java.lang.String
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
private static method getS$delegate(): java.lang.Object
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,10 @@
@kotlin.Metadata
public final class DelegateToConstKt {
// source: 'delegateToConst.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
private static method getS$delegate(): java.lang.Object
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,8 @@
// CHECK_BYTECODE_LISTING
operator fun Any?.getValue(thisRef: Any?, property: Any?) =
if (this == null && thisRef == null) "OK" else "Failed"
val s: String by null
fun box() = s
@@ -0,0 +1,10 @@
@kotlin.Metadata
public final class DelegateToNullKt {
// source: 'delegateToNull.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static @org.jetbrains.annotations.NotNull field s$delegate: java.lang.Void
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,10 @@
@kotlin.Metadata
public final class DelegateToNullKt {
// source: 'delegateToNull.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
private static method getS$delegate(): java.lang.Object
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,26 @@
// CHECK_BYTECODE_LISTING
class A {
val b = B()
}
class B {
val c = C()
}
class C {
val d = D()
}
class D {
val e = 1
}
val a = A()
operator fun Int.getValue(thisRef: Any?, property: Any?) =
if (this == 1 && thisRef == null) "OK" else "Failed"
val x by a.b.c.d.e
fun box() = x
@@ -0,0 +1,44 @@
@kotlin.Metadata
public final class A {
// source: 'chain.kt'
private final @org.jetbrains.annotations.NotNull field b: B
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getB(): B
}
@kotlin.Metadata
public final class B {
// source: 'chain.kt'
private final @org.jetbrains.annotations.NotNull field c: C
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getC(): C
}
@kotlin.Metadata
public final class C {
// source: 'chain.kt'
private final @org.jetbrains.annotations.NotNull field d: D
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getD(): D
}
@kotlin.Metadata
public final class ChainKt {
// source: 'chain.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static @org.jetbrains.annotations.NotNull field a: A
private final static field x$delegate: int
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getA(): A
public final static @org.jetbrains.annotations.NotNull method getValue(p0: int, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getX(): java.lang.String
}
@kotlin.Metadata
public final class D {
// source: 'chain.kt'
private final field e: int
public method <init>(): void
public final method getE(): int
}
@@ -0,0 +1,44 @@
@kotlin.Metadata
public final class A {
// source: 'chain.kt'
private final @org.jetbrains.annotations.NotNull field b: B
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getB(): B
}
@kotlin.Metadata
public final class B {
// source: 'chain.kt'
private final @org.jetbrains.annotations.NotNull field c: C
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getC(): C
}
@kotlin.Metadata
public final class C {
// source: 'chain.kt'
private final @org.jetbrains.annotations.NotNull field d: D
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getD(): D
}
@kotlin.Metadata
public final class ChainKt {
// source: 'chain.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static @org.jetbrains.annotations.NotNull field a: A
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getA(): A
public final static @org.jetbrains.annotations.NotNull method getValue(p0: int, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
private static method getX$delegate(): java.lang.Object
public final static @org.jetbrains.annotations.NotNull method getX(): java.lang.String
}
@kotlin.Metadata
public final class D {
// source: 'chain.kt'
private final field e: int
public method <init>(): void
public final method getE(): int
}
@@ -0,0 +1,14 @@
// CHECK_BYTECODE_LISTING
class C {
val impl = 123
val s: String by impl
}
val c = C()
operator fun Any?.getValue(thisRef: Any?, property: Any?) =
if (this == 123 && thisRef == c) "OK" else "Failed"
fun box() = c.s
@@ -0,0 +1,21 @@
@kotlin.Metadata
public final class C {
// source: 'delegateToFinalInstanceProperty.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final field impl: int
private final field s$delegate: int
static method <clinit>(): void
public method <init>(): void
public final method getImpl(): int
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
}
@kotlin.Metadata
public final class DelegateToFinalInstancePropertyKt {
// source: 'delegateToFinalInstanceProperty.kt'
private final static @org.jetbrains.annotations.NotNull field c: C
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getC(): C
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,21 @@
@kotlin.Metadata
public final class C {
// source: 'delegateToFinalInstanceProperty.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final field impl: int
static method <clinit>(): void
public method <init>(): void
public final method getImpl(): int
private static method getS$delegate(p0: C): java.lang.Object
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
}
@kotlin.Metadata
public final class DelegateToFinalInstancePropertyKt {
// source: 'delegateToFinalInstanceProperty.kt'
private final static @org.jetbrains.annotations.NotNull field c: C
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getC(): C
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,12 @@
// CHECK_BYTECODE_LISTING
object O {
val impl = 123
}
operator fun Any?.getValue(thisRef: Any?, property: Any?) =
if (this == 123 && thisRef == null) "OK" else "Failed"
val s: String by O.impl
fun box() = s
@@ -0,0 +1,20 @@
@kotlin.Metadata
public final class DelegateToFinalObjectPropertyKt {
// source: 'delegateToFinalObjectProperty.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static field s$delegate: int
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final class O {
// source: 'delegateToFinalObjectProperty.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
private final static field impl: int
static method <clinit>(): void
private method <init>(): void
public final method getImpl(): int
}
@@ -0,0 +1,20 @@
@kotlin.Metadata
public final class DelegateToFinalObjectPropertyKt {
// source: 'delegateToFinalObjectProperty.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
private static method getS$delegate(): java.lang.Object
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final class O {
// source: 'delegateToFinalObjectProperty.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
private final static field impl: int
static method <clinit>(): void
private method <init>(): void
public final method getImpl(): int
}
@@ -0,0 +1,10 @@
// CHECK_BYTECODE_LISTING
val impl = 123
operator fun Any?.getValue(thisRef: Any?, property: Any?) =
if (this == 123 && thisRef == null) "OK" else "Failed"
val s: String by impl
fun box() = s
@@ -0,0 +1,12 @@
@kotlin.Metadata
public final class DelegateToFinalPropertyKt {
// source: 'delegateToFinalProperty.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static field impl: int
private final static field s$delegate: int
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method getImpl(): int
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,12 @@
@kotlin.Metadata
public final class DelegateToFinalPropertyKt {
// source: 'delegateToFinalProperty.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static field impl: int
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method getImpl(): int
private static method getS$delegate(): java.lang.Object
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,12 @@
// CHECK_BYTECODE_LISTING
//FILE file1.kt
val impl = 123
//FILE file2.kt
operator fun Any?.getValue(thisRef: Any?, property: Any?) =
if (this == 123 && thisRef == null) "OK" else "Failed"
val s: String by impl
fun box() = s
@@ -0,0 +1,12 @@
@kotlin.Metadata
public final class FinalPropertyInAnotherFileKt {
// source: 'finalPropertyInAnotherFile.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static field impl: int
private final static field s$delegate: int
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method getImpl(): int
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,12 @@
@kotlin.Metadata
public final class FinalPropertyInAnotherFileKt {
// source: 'finalPropertyInAnotherFile.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static field impl: int
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method getImpl(): int
private static method getS$delegate(): java.lang.Object
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,18 @@
// FILE: 1.kt
var result = "Fail"
val unused by c
fun box(): String = result
// FILE: 2.kt
class C {
init {
result = "OK"
}
}
operator fun C.getValue(x: Any?, y: Any?): String = throw IllegalStateException()
val c = C()
@@ -0,0 +1,18 @@
// CHECK_BYTECODE_LISTING
import O.d
enum class E { X }
object O {
val E.d: Delegate get() = Delegate()
}
class Delegate {
operator fun getValue(thisRef: Any?, property: Any?) =
if (thisRef == null) "OK" else "Failed"
}
val result by E.X.d
fun box(): String = result
@@ -0,0 +1,36 @@
@kotlin.Metadata
public final class Delegate {
// source: 'memberExtensionPropertyAndImportFromObject.kt'
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final enum class E {
// source: 'memberExtensionPropertyAndImportFromObject.kt'
private synthetic final static field $VALUES: E[]
public final enum static field X: E
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static method valueOf(p0: java.lang.String): E
public static method values(): E[]
}
@kotlin.Metadata
public final class MemberExtensionPropertyAndImportFromObjectKt {
// source: 'memberExtensionPropertyAndImportFromObject.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static @org.jetbrains.annotations.NotNull field result$delegate: Delegate
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getResult(): java.lang.String
}
@kotlin.Metadata
public final class O {
// source: 'memberExtensionPropertyAndImportFromObject.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
static method <clinit>(): void
private method <init>(): void
public final @org.jetbrains.annotations.NotNull method getD(@org.jetbrains.annotations.NotNull p0: E): Delegate
}
@@ -0,0 +1,37 @@
@kotlin.Metadata
public final class Delegate {
// source: 'memberExtensionPropertyAndImportFromObject.kt'
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final enum class E {
// source: 'memberExtensionPropertyAndImportFromObject.kt'
private synthetic final static field $VALUES: E[]
public final enum static field X: E
private synthetic final static method $values(): E[]
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static method valueOf(p0: java.lang.String): E
public static method values(): E[]
}
@kotlin.Metadata
public final class MemberExtensionPropertyAndImportFromObjectKt {
// source: 'memberExtensionPropertyAndImportFromObject.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static @org.jetbrains.annotations.NotNull field result$delegate: Delegate
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getResult(): java.lang.String
}
@kotlin.Metadata
public final class O {
// source: 'memberExtensionPropertyAndImportFromObject.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
static method <clinit>(): void
private method <init>(): void
public final @org.jetbrains.annotations.NotNull method getD(@org.jetbrains.annotations.NotNull p0: E): Delegate
}
@@ -0,0 +1,17 @@
// CHECK_BYTECODE_LISTING
enum class E { X }
object O {
val E.d: Delegate get() = Delegate()
}
class Delegate {
operator fun getValue(thisRef: Any?, property: Any?) =
if (thisRef == null) "OK" else "Failed"
}
fun box(): String = with(O) {
val result by E.X.d
result
}
@@ -0,0 +1,34 @@
@kotlin.Metadata
public final class Delegate {
// source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt'
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final enum class E {
// source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt'
private synthetic final static field $VALUES: E[]
public final enum static field X: E
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static method valueOf(p0: java.lang.String): E
public static method values(): E[]
}
@kotlin.Metadata
public final class MemberExtensionPropertyAndLocalDelegatedPropertyKt {
// source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
}
@kotlin.Metadata
public final class O {
// source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
static method <clinit>(): void
private method <init>(): void
public final @org.jetbrains.annotations.NotNull method getD(@org.jetbrains.annotations.NotNull p0: E): Delegate
}
@@ -0,0 +1,36 @@
@kotlin.Metadata
public final class Delegate {
// source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt'
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final enum class E {
// source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt'
private synthetic final static field $VALUES: E[]
public final enum static field X: E
private synthetic final static method $values(): E[]
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static method valueOf(p0: java.lang.String): E
public static method values(): E[]
}
@kotlin.Metadata
public final class MemberExtensionPropertyAndLocalDelegatedPropertyKt {
// source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
static method <clinit>(): void
private final static method box$lambda-1$lambda-0(p0: Delegate): java.lang.String
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
}
@kotlin.Metadata
public final class O {
// source: 'memberExtensionPropertyAndLocalDelegatedProperty.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
static method <clinit>(): void
private method <init>(): void
public final @org.jetbrains.annotations.NotNull method getD(@org.jetbrains.annotations.NotNull p0: E): Delegate
}
@@ -0,0 +1,14 @@
// TARGET_BACKEND: JVM
// CHECK_BYTECODE_LISTING
// MODULE: lib
// FILE: file1.kt
val impl = 123
// MODULE: main(lib)
// FILE: file2.kt
operator fun Any?.getValue(thisRef: Any?, property: Any?) = "OK"
val s: String by impl
fun box() = s
@@ -0,0 +1,19 @@
Module: lib
@kotlin.Metadata
public final class File1Kt {
// source: 'file1.kt'
private final static field impl: int
static method <clinit>(): void
public final static method getImpl(): int
}
Module: main
@kotlin.Metadata
public final class File2Kt {
// source: 'file2.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static field s$delegate: int
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,13 @@
// WITH_STDLIB
// CHECK_BYTECODE_LISTING
enum class E {
OK, NOT_OK
}
operator fun E.getValue(thisRef: Any?, property: Any?): String =
if (this == E.OK && thisRef == null) "OK" else "Failed"
val s: String by E.OK
fun box(): String = s
@@ -0,0 +1,22 @@
@kotlin.Metadata
public final class DelegateToEnumKt {
// source: 'delegateToEnum.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static @org.jetbrains.annotations.NotNull field s$delegate: E
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: E, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final enum class E {
// source: 'delegateToEnum.kt'
private synthetic final static field $VALUES: E[]
public final enum static field NOT_OK: E
public final enum static field OK: E
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static method valueOf(p0: java.lang.String): E
public static method values(): E[]
}
@@ -0,0 +1,17 @@
// WITH_STDLIB
// CHECK_BYTECODE_LISTING
enum class E {
OK, NOT_OK
}
class C {
val s: String by E.OK
}
val c = C()
operator fun E.getValue(thisRef: Any?, property: Any?): String =
if (this == E.OK && thisRef == c) "OK" else "Failed"
fun box(): String = c.s
@@ -0,0 +1,31 @@
@kotlin.Metadata
public final class C {
// source: 'delegateToEnumInAClass.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final @org.jetbrains.annotations.NotNull field s$delegate: E
static method <clinit>(): void
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
}
@kotlin.Metadata
public final class DelegateToEnumInAClassKt {
// source: 'delegateToEnumInAClass.kt'
private final static @org.jetbrains.annotations.NotNull field c: C
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getC(): C
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: E, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final enum class E {
// source: 'delegateToEnumInAClass.kt'
private synthetic final static field $VALUES: E[]
public final enum static field NOT_OK: E
public final enum static field OK: E
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static method valueOf(p0: java.lang.String): E
public static method values(): E[]
}
@@ -0,0 +1,32 @@
@kotlin.Metadata
public final class C {
// source: 'delegateToEnumInAClass.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
static method <clinit>(): void
public method <init>(): void
private static method getS$delegate(p0: C): java.lang.Object
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
}
@kotlin.Metadata
public final class DelegateToEnumInAClassKt {
// source: 'delegateToEnumInAClass.kt'
private final static @org.jetbrains.annotations.NotNull field c: C
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getC(): C
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: E, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final enum class E {
// source: 'delegateToEnumInAClass.kt'
private synthetic final static field $VALUES: E[]
public final enum static field NOT_OK: E
public final enum static field OK: E
private synthetic final static method $values(): E[]
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static method valueOf(p0: java.lang.String): E
public static method values(): E[]
}
@@ -0,0 +1,23 @@
@kotlin.Metadata
public final class DelegateToEnumKt {
// source: 'delegateToEnum.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
private static method getS$delegate(): java.lang.Object
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: E, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final enum class E {
// source: 'delegateToEnum.kt'
private synthetic final static field $VALUES: E[]
public final enum static field NOT_OK: E
public final enum static field OK: E
private synthetic final static method $values(): E[]
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static method valueOf(p0: java.lang.String): E
public static method values(): E[]
}
@@ -0,0 +1,25 @@
// WITH_STDLIB
// CHECK_BYTECODE_LISTING
// IGNORE_BACKEND: JS_IR
import kotlin.reflect.KProperty
import kotlin.test.assertEquals
object Store {
private val map = mutableMapOf<Pair<Any?, KProperty<*>>, String?>()
operator fun getValue(thisRef: Any?, property: KProperty<*>): String? = map[thisRef to property]
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String?) {
map[thisRef to property] = value
}
}
object O {
var s: String? by Store
}
fun box(): String? {
O.s = "OK"
return O.s
}
@@ -0,0 +1,28 @@
@kotlin.Metadata
public final class DelegateToSingletonKt {
// source: 'delegateToSingleton.kt'
public final static @org.jetbrains.annotations.Nullable method box(): java.lang.String
}
@kotlin.Metadata
public final class O {
// source: 'delegateToSingleton.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
private final static @org.jetbrains.annotations.Nullable field s$delegate: Store
static method <clinit>(): void
private method <init>(): void
public final @org.jetbrains.annotations.Nullable method getS(): java.lang.String
public final method setS(@org.jetbrains.annotations.Nullable p0: java.lang.String): void
}
@kotlin.Metadata
public final class Store {
// source: 'delegateToSingleton.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: Store
private final static field map: java.util.Map
static method <clinit>(): void
private method <init>(): void
public final @org.jetbrains.annotations.Nullable method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.reflect.KProperty): java.lang.String
public final method setValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.reflect.KProperty, @org.jetbrains.annotations.Nullable p2: java.lang.String): void
}
@@ -0,0 +1,28 @@
@kotlin.Metadata
public final class DelegateToSingletonKt {
// source: 'delegateToSingleton.kt'
public final static @org.jetbrains.annotations.Nullable method box(): java.lang.String
}
@kotlin.Metadata
public final class O {
// source: 'delegateToSingleton.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
static method <clinit>(): void
private method <init>(): void
private static method getS$delegate(p0: O): java.lang.Object
public final @org.jetbrains.annotations.Nullable method getS(): java.lang.String
public final method setS(@org.jetbrains.annotations.Nullable p0: java.lang.String): void
}
@kotlin.Metadata
public final class Store {
// source: 'delegateToSingleton.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: Store
private final static @org.jetbrains.annotations.NotNull field map: java.util.Map
static method <clinit>(): void
private method <init>(): void
public final @org.jetbrains.annotations.Nullable method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.reflect.KProperty): java.lang.String
public final method setValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.reflect.KProperty, @org.jetbrains.annotations.Nullable p2: java.lang.String): void
}
@@ -0,0 +1,15 @@
// WITH_STDLIB
// CHECK_BYTECODE_LISTING
object O {
object P
init {
throw IllegalStateException("O should not be initialized")
}
}
operator fun O.P.getValue(thisRef: Any?, property: Any?) = if (thisRef == null) "OK" else "Failed"
val result by O.P
fun box(): String = result
@@ -0,0 +1,28 @@
@kotlin.Metadata
public final class NoInitializationOfOuterClassKt {
// source: 'noInitializationOfOuterClass.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final static @org.jetbrains.annotations.NotNull field result$delegate: O$P
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getResult(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: O$P, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final class O$P {
// source: 'noInitializationOfOuterClass.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O$P
static method <clinit>(): void
private method <init>(): void
public final inner class O$P
}
@kotlin.Metadata
public final class O {
// source: 'noInitializationOfOuterClass.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
static method <clinit>(): void
private method <init>(): void
public final inner class O$P
}
@@ -0,0 +1,28 @@
@kotlin.Metadata
public final class NoInitializationOfOuterClassKt {
// source: 'noInitializationOfOuterClass.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
private static method getResult$delegate(): java.lang.Object
public final static @org.jetbrains.annotations.NotNull method getResult(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: O$P, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final class O$P {
// source: 'noInitializationOfOuterClass.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O$P
static method <clinit>(): void
private method <init>(): void
public final inner class O$P
}
@kotlin.Metadata
public final class O {
// source: 'noInitializationOfOuterClass.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
static method <clinit>(): void
private method <init>(): void
public final inner class O$P
}
@@ -0,0 +1,23 @@
// WITH_STDLIB
// CHECK_BYTECODE_LISTING
var initialized = false
object O {
init {
initialized = true
}
operator fun getValue(x: Any?, y: Any?): String {
throw RuntimeException()
}
}
class C {
val s: String by O
}
fun box(): String {
val c = C()
return if (initialized) "OK" else "FAILURE"
}
@@ -0,0 +1,27 @@
@kotlin.Metadata
public final class C {
// source: 'withSideEffects.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final @org.jetbrains.annotations.NotNull field s$delegate: O
static method <clinit>(): void
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
}
@kotlin.Metadata
public final class O {
// source: 'withSideEffects.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
static method <clinit>(): void
private method <init>(): void
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final class WithSideEffectsKt {
// source: 'withSideEffects.kt'
private static field initialized: boolean
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method getInitialized(): boolean
public final static method setInitialized(p0: boolean): void
}
@@ -0,0 +1,19 @@
// WITH_STDLIB
// CHECK_BYTECODE_LISTING
var initialized = false
object O {
init {
initialized = true
}
operator fun getValue(x: Any?, y: Any?): String {
throw RuntimeException()
}
}
val s: String by O
fun box(): String = if (initialized) "OK" else "FAILURE"
@@ -0,0 +1,21 @@
@kotlin.Metadata
public final class O {
// source: 'withSideEffectsFromFileClass.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
static method <clinit>(): void
private method <init>(): void
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final class WithSideEffectsFromFileClassKt {
// source: 'withSideEffectsFromFileClass.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private static field initialized: boolean
private final static @org.jetbrains.annotations.NotNull field s$delegate: O
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method getInitialized(): boolean
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static method setInitialized(p0: boolean): void
}
@@ -0,0 +1,21 @@
@kotlin.Metadata
public final class O {
// source: 'withSideEffectsFromFileClass.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
static method <clinit>(): void
private method <init>(): void
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final class WithSideEffectsFromFileClassKt {
// source: 'withSideEffectsFromFileClass.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private static field initialized: boolean
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method getInitialized(): boolean
private static method getS$delegate(): java.lang.Object
public final static @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final static method setInitialized(p0: boolean): void
}
@@ -0,0 +1,22 @@
// WITH_STDLIB
// CHECK_BYTECODE_LISTING
var initialized = false
enum class E {
X;
companion object {
init {
initialized = true
}
}
}
operator fun Any?.getValue(x: Any?, y: Any?): String {
throw RuntimeException()
}
val result by E.X
fun box() = if (initialized) "OK" else "FAILURE"
@@ -0,0 +1,34 @@
@kotlin.Metadata
public final class E$Companion {
// source: 'withSideEffectsToEnum.kt'
private method <init>(): void
public synthetic method <init>(p0: kotlin.jvm.internal.DefaultConstructorMarker): void
public final inner class E$Companion
}
@kotlin.Metadata
public final enum class E {
// source: 'withSideEffectsToEnum.kt'
private synthetic final static field $VALUES: E[]
public final static @org.jetbrains.annotations.NotNull field Companion: E$Companion
public final enum static field X: E
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static method valueOf(p0: java.lang.String): E
public static method values(): E[]
public final inner class E$Companion
}
@kotlin.Metadata
public final class WithSideEffectsToEnumKt {
// source: 'withSideEffectsToEnum.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private static field initialized: boolean
private final static @org.jetbrains.annotations.NotNull field result$delegate: E
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method getInitialized(): boolean
public final static @org.jetbrains.annotations.NotNull method getResult(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
public final static method setInitialized(p0: boolean): void
}
@@ -0,0 +1,35 @@
@kotlin.Metadata
public final class E$Companion {
// source: 'withSideEffectsToEnum.kt'
private method <init>(): void
public synthetic method <init>(p0: kotlin.jvm.internal.DefaultConstructorMarker): void
public final inner class E$Companion
}
@kotlin.Metadata
public final enum class E {
// source: 'withSideEffectsToEnum.kt'
private synthetic final static field $VALUES: E[]
public final static @org.jetbrains.annotations.NotNull field Companion: E$Companion
public final enum static field X: E
private synthetic final static method $values(): E[]
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static method valueOf(p0: java.lang.String): E
public static method values(): E[]
public final inner class E$Companion
}
@kotlin.Metadata
public final class WithSideEffectsToEnumKt {
// source: 'withSideEffectsToEnum.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private static field initialized: boolean
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method getInitialized(): boolean
private static method getResult$delegate(): java.lang.Object
public final static @org.jetbrains.annotations.NotNull method getResult(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
public final static method setInitialized(p0: boolean): void
}
@@ -0,0 +1,28 @@
@kotlin.Metadata
public final class C {
// source: 'withSideEffects.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
static method <clinit>(): void
public method <init>(): void
private static method getS$delegate(p0: C): java.lang.Object
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
}
@kotlin.Metadata
public final class O {
// source: 'withSideEffects.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
static method <clinit>(): void
private method <init>(): void
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final class WithSideEffectsKt {
// source: 'withSideEffects.kt'
private static field initialized: boolean
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method getInitialized(): boolean
public final static method setInitialized(p0: boolean): void
}
@@ -0,0 +1,13 @@
// WITH_STDLIB
// CHECK_BYTECODE_LISTING
class O {
operator fun getValue(thisRef: Any?, property: Any?) =
if (thisRef is I) "OK" else "Failed"
inner class I {
val s: String by this@O
}
}
fun box() = O().I().s
@@ -0,0 +1,25 @@
@kotlin.Metadata
public final class DelegateToOuterThisKt {
// source: 'delegateToOuterThis.kt'
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
}
@kotlin.Metadata
public final class O$I {
// source: 'delegateToOuterThis.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final @org.jetbrains.annotations.NotNull field s$delegate: O
synthetic final field this$0: O
static method <clinit>(): void
public method <init>(p0: O): void
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final inner class O$I
}
@kotlin.Metadata
public final class O {
// source: 'delegateToOuterThis.kt'
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String
public final inner class O$I
}
@@ -0,0 +1,25 @@
@kotlin.Metadata
public final class DelegateToOuterThisKt {
// source: 'delegateToOuterThis.kt'
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
}
@kotlin.Metadata
public final class O$I {
// source: 'delegateToOuterThis.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
synthetic final field this$0: O
static method <clinit>(): void
public method <init>(p0: O): void
private static method getS$delegate(p0: O$I): java.lang.Object
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final inner class O$I
}
@kotlin.Metadata
public final class O {
// source: 'delegateToOuterThis.kt'
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String
public final inner class O$I
}
@@ -0,0 +1,11 @@
// WITH_STDLIB
// CHECK_BYTECODE_LISTING
class C {
operator fun getValue(thisRef: Any?, property: Any?) =
if (thisRef == this) "OK" else "Failed"
val s: String by this
}
fun box() = C().s
@@ -0,0 +1,16 @@
@kotlin.Metadata
public final class C {
// source: 'delegateToThis.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final @org.jetbrains.annotations.NotNull field s$delegate: C
static method <clinit>(): void
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final class DelegateToThisKt {
// source: 'delegateToThis.kt'
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
}
@@ -0,0 +1,13 @@
// WITH_STDLIB
// CHECK_BYTECODE_LISTING
class C {
val s: String by this
}
val c = C()
operator fun C.getValue(thisRef: Any?, property: Any?) =
if (this == c && thisRef == c) "OK" else "Failed"
fun box() = c.s
@@ -0,0 +1,19 @@
@kotlin.Metadata
public final class C {
// source: 'delegateToThisByExtension.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
private final @org.jetbrains.annotations.NotNull field s$delegate: C
static method <clinit>(): void
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
}
@kotlin.Metadata
public final class DelegateToThisByExtensionKt {
// source: 'delegateToThisByExtension.kt'
private final static @org.jetbrains.annotations.NotNull field c: C
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getC(): C
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: C, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,19 @@
@kotlin.Metadata
public final class C {
// source: 'delegateToThisByExtension.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
static method <clinit>(): void
public method <init>(): void
private static method getS$delegate(p0: C): java.lang.Object
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
}
@kotlin.Metadata
public final class DelegateToThisByExtensionKt {
// source: 'delegateToThisByExtension.kt'
private final static @org.jetbrains.annotations.NotNull field c: C
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getC(): C
public final static @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.NotNull p0: C, @org.jetbrains.annotations.Nullable p1: java.lang.Object, @org.jetbrains.annotations.Nullable p2: java.lang.Object): java.lang.String
}
@@ -0,0 +1,16 @@
@kotlin.Metadata
public final class C {
// source: 'delegateToThis.kt'
synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[]
static method <clinit>(): void
public method <init>(): void
private static method getS$delegate(p0: C): java.lang.Object
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
public final @org.jetbrains.annotations.NotNull method getValue(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Object): java.lang.String
}
@kotlin.Metadata
public final class DelegateToThisKt {
// source: 'delegateToThis.kt'
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
}
@@ -22,7 +22,7 @@ object Delegate {
fun box(): String {
assertEquals(
listOf("getIsFries", "getIsUpdateable", "setIsFries", "setIsUpdateable"),
TestIt::class.java.declaredMethods.map { it.name }.sorted()
TestIt::class.java.declaredMethods.map { it.name }.sorted() - "getIsUpdateable\$delegate"
)
return "OK"
@@ -0,0 +1,17 @@
// TARGET_BACKEND: JVM
// WITH_REFLECT
import kotlin.test.assertEquals
import kotlin.reflect.jvm.isAccessible
operator fun Any?.getValue(x: Any?, y: Any?): String {
return "OK"
}
val s: String by 1
fun box(): String {
assertEquals(1, ::s.apply { isAccessible = true }.getDelegate())
return "OK"
}
@@ -0,0 +1,18 @@
// TARGET_BACKEND: JVM
// WITH_REFLECT
import kotlin.reflect.jvm.isAccessible
import kotlin.test.assertEquals
operator fun Any?.getValue(x: Any?, y: Any?): String {
return "OK"
}
const val a = "TEXT"
val s: String by a
fun box(): String {
assertEquals("TEXT", ::s.apply { isAccessible = true }.getDelegate())
return "OK"
}
@@ -0,0 +1,18 @@
// TARGET_BACKEND: JVM
// WITH_REFLECT
import kotlin.test.assertEquals
import kotlin.reflect.jvm.isAccessible
enum class E {
OK, NOT_OK
}
operator fun E.getValue(x: Any?, y: Any?): String = name
val s: String by E.OK
fun box(): String {
assertEquals(E.OK, ::s.apply { isAccessible = true }.getDelegate())
return "OK"
}
@@ -0,0 +1,21 @@
// TARGET_BACKEND: JVM
// WITH_REFLECT
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
import kotlin.reflect.jvm.isAccessible
import kotlin.test.assertEquals
object O {
val impl = 123
}
operator fun Any?.getValue(thisRef: Any?, property: KProperty<*>) = "OK"
val s: String by O.impl
fun box(): String {
assertEquals(123, ::s.apply { isAccessible = true }.getDelegate())
return "OK"
}
@@ -0,0 +1,18 @@
// TARGET_BACKEND: JVM
// WITH_REFLECT
import kotlin.reflect.KProperty
import kotlin.reflect.jvm.isAccessible
import kotlin.test.assertEquals
val impl = 123
operator fun Any?.getValue(thisRef: Any?, property: KProperty<*>) = "OK"
val s: String by impl
fun box(): String {
assertEquals(123, ::s.apply { isAccessible = true }.getDelegate())
return "OK"
}
@@ -0,0 +1,27 @@
// TARGET_BACKEND: JVM
// WITH_REFLECT
import kotlin.reflect.KProperty
import kotlin.reflect.jvm.isAccessible
import kotlin.test.assertEquals
object Store {
private val map = mutableMapOf<Pair<Any?, KProperty<*>>, String?>()
operator fun getValue(thisRef: Any?, property: KProperty<*>): String? = map[thisRef to property]
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String?) {
map[thisRef to property] = value
}
}
object O {
var s: String? by Store
}
fun box(): String {
assertEquals(Store, O::s.apply { isAccessible = true }.getDelegate())
return "OK"
}