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
}