KT-14513 Don't generate delegated property metadata when unused
If the delegated property operators involved are inline, and delegated property metadata parameter is not used (which is often the case, e.g., 'lazy'), we can skip those properties in metadata generation. NOT implemented: special case when only 'kProperty.name' is used by the corresponding delegated property operators. Also a sneak fix for KT-34060.
This commit is contained in:
committed by
Dmitry Petrov
parent
92ba298e68
commit
a633a33627
+12
-3
@@ -16,13 +16,22 @@ fun f(a: Int, b: Int, <!UNUSED_PARAMETER!>c<!>: Int = b) {
|
||||
a + a
|
||||
}
|
||||
|
||||
fun Any.getValue(thisRef: Any?, prop: KProperty<*>): String = ":)"
|
||||
fun Any.setValue(thisRef: Any?, prop: KProperty<*>, value: String) {
|
||||
fun Any.getValue(<!UNUSED_PARAMETER!>thisRef<!>: Any?, <!UNUSED_PARAMETER!>prop<!>: KProperty<*>): String = ":)"
|
||||
fun Any.setValue(<!UNUSED_PARAMETER!>thisRef<!>: Any?, <!UNUSED_PARAMETER!>prop<!>: KProperty<*>, <!UNUSED_PARAMETER!>value<!>: String) {
|
||||
}
|
||||
|
||||
fun Any.provideDelegate(thisRef: Any?, prop: KProperty<*>) {
|
||||
fun Any.provideDelegate(<!UNUSED_PARAMETER!>thisRef<!>: Any?, <!UNUSED_PARAMETER!>prop<!>: KProperty<*>) {
|
||||
}
|
||||
|
||||
operator fun Int.getValue(thisRef: Any?, prop: KProperty<*>): String = ":)"
|
||||
|
||||
operator fun Int.setValue(thisRef: Any?, prop: KProperty<*>, value: String) {
|
||||
}
|
||||
|
||||
operator fun Int.provideDelegate(thisRef: Any?, prop: KProperty<*>) {
|
||||
}
|
||||
|
||||
|
||||
fun get(<!UNUSED_PARAMETER!>p<!>: Any) {
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,11 @@ public fun foo(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
public fun get(/*0*/ p: kotlin.Any): kotlin.Unit
|
||||
public fun set(/*0*/ p: kotlin.Any): kotlin.Unit
|
||||
public fun kotlin.Any.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.reflect.KProperty<*>): kotlin.String
|
||||
public operator fun kotlin.Int.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.reflect.KProperty<*>): kotlin.String
|
||||
public fun kotlin.Any.provideDelegate(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.reflect.KProperty<*>): kotlin.Unit
|
||||
public operator fun kotlin.Int.provideDelegate(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.reflect.KProperty<*>): kotlin.Unit
|
||||
public fun kotlin.Any.setValue(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.reflect.KProperty<*>, /*2*/ value: kotlin.String): kotlin.Unit
|
||||
public operator fun kotlin.Int.setValue(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.reflect.KProperty<*>, /*2*/ value: kotlin.String): kotlin.Unit
|
||||
|
||||
public final class C {
|
||||
public constructor C(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int, /*2*/ c: kotlin.Int, /*3*/ d: kotlin.Int, /*4*/ e: kotlin.Int = ..., /*5*/ f: kotlin.String)
|
||||
|
||||
+1
-1
@@ -3,5 +3,5 @@ import kotlin.reflect.KProperty0
|
||||
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>A()<!>
|
||||
|
||||
class A {
|
||||
fun getValue(t: Any?, p: KProperty0<*>): Int = 1
|
||||
fun getValue(<!UNUSED_PARAMETER!>t<!>: Any?, <!UNUSED_PARAMETER!>p<!>: KProperty0<*>): Int = 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user