JVM_IR: optimize out redundant delegated property receiver fields

Now this:

    class C {
        val x = something
        val y by x::property
    }

is *exactly* the same as this:

    class C {
        val x = something
        val y get() = x.property
    }

(plus a `getY$delegate` method)
This commit is contained in:
pyos
2021-07-02 12:35:02 +02:00
committed by Alexander Udalov
parent 2fe7cf27ad
commit d988853c11
11 changed files with 175 additions and 17 deletions
@@ -33,6 +33,7 @@ fun local() {
// Optimized all to direct accesses, with `$delegate` methods generating reflected references on demand:
// 0 extends kotlin/jvm/internal/MutablePropertyReference[0-2]Impl
// 0 private final( static)? Lkotlin/reflect/KMutableProperty[0-2]; [xyz]m?\$delegate
// 2 private final( static)? LC; [xyz]m?\$receiver
// 0 LOCALVARIABLE [xyz]m? Lkotlin/reflect/KMutableProperty[0-2];
// 12 static get[XYZ]m?\$delegate