JVM IR: change generation scheme of property $delegate methods
Generate $delegate method as instance method in PropertyReferenceDelegationLowering, and remove dispatch receiver later in MakePropertyDelegateMethodsStatic. The method needs to be static to be non-overridable (see delegateMethodIsNonOverridable.kt), and public to be accessible in reflection. Otherwise we generated incorrect IR where a static function accessed an instance field of the containing class, which failed in multiple places including LocalDeclarationsLowering. #KT-48350 Fixed
This commit is contained in:
committed by
Alexander Udalov
parent
50508da156
commit
04c5bbdcf8
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
val a = 1
|
||||
val b = 2
|
||||
|
||||
open class C {
|
||||
open val x by run { ::a }
|
||||
open val y by ::a
|
||||
}
|
||||
|
||||
class D : C() {
|
||||
override val x by run { ::b }
|
||||
override val y by ::b
|
||||
}
|
||||
Vendored
+65
@@ -0,0 +1,65 @@
|
||||
@kotlin.Metadata
|
||||
synthetic final class C$x$2$1 {
|
||||
// source: 'delegateMethodIsNonOverridable.kt'
|
||||
public final static field INSTANCE: kotlin.reflect.KProperty0
|
||||
static method <clinit>(): void
|
||||
method <init>(): void
|
||||
public @org.jetbrains.annotations.Nullable method get(): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
synthetic final class C$y$2 {
|
||||
// source: 'delegateMethodIsNonOverridable.kt'
|
||||
public final static field INSTANCE: kotlin.reflect.KProperty0
|
||||
static method <clinit>(): void
|
||||
method <init>(): void
|
||||
public @org.jetbrains.annotations.Nullable method get(): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public class C {
|
||||
// source: 'delegateMethodIsNonOverridable.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field x$delegate: kotlin.reflect.KProperty0
|
||||
private final @org.jetbrains.annotations.NotNull field y$delegate: kotlin.reflect.KProperty0
|
||||
public method <init>(): void
|
||||
public method getX(): int
|
||||
public method getY(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
synthetic final class D$x$2$1 {
|
||||
// source: 'delegateMethodIsNonOverridable.kt'
|
||||
public final static field INSTANCE: kotlin.reflect.KProperty0
|
||||
static method <clinit>(): void
|
||||
method <init>(): void
|
||||
public @org.jetbrains.annotations.Nullable method get(): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
synthetic final class D$y$2 {
|
||||
// source: 'delegateMethodIsNonOverridable.kt'
|
||||
public final static field INSTANCE: kotlin.reflect.KProperty0
|
||||
static method <clinit>(): void
|
||||
method <init>(): void
|
||||
public @org.jetbrains.annotations.Nullable method get(): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class D {
|
||||
// source: 'delegateMethodIsNonOverridable.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field x$delegate: kotlin.reflect.KProperty0
|
||||
private final @org.jetbrains.annotations.NotNull field y$delegate: kotlin.reflect.KProperty0
|
||||
public method <init>(): void
|
||||
public method getX(): int
|
||||
public method getY(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class DelegateMethodIsNonOverridableKt {
|
||||
// source: 'delegateMethodIsNonOverridable.kt'
|
||||
private final static field a: int
|
||||
private final static field b: int
|
||||
static method <clinit>(): void
|
||||
public final static method getA(): int
|
||||
public final static method getB(): int
|
||||
}
|
||||
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
@kotlin.Metadata
|
||||
synthetic final class C$x$2$1 {
|
||||
// source: 'delegateMethodIsNonOverridable.kt'
|
||||
enclosing method C.<init>()V
|
||||
public final static field INSTANCE: C$x$2$1
|
||||
inner (anonymous) class C$x$2$1
|
||||
static method <clinit>(): void
|
||||
method <init>(): void
|
||||
public @org.jetbrains.annotations.Nullable method get(): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public class C {
|
||||
// source: 'delegateMethodIsNonOverridable.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field x$delegate: kotlin.reflect.KProperty0
|
||||
inner (anonymous) class C$x$2$1
|
||||
public method <init>(): void
|
||||
public method getX(): int
|
||||
public static method getY$delegate(p0: C): java.lang.Object
|
||||
public method getY(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
synthetic final class D$x$2$1 {
|
||||
// source: 'delegateMethodIsNonOverridable.kt'
|
||||
enclosing method D.<init>()V
|
||||
public final static field INSTANCE: D$x$2$1
|
||||
inner (anonymous) class D$x$2$1
|
||||
static method <clinit>(): void
|
||||
method <init>(): void
|
||||
public @org.jetbrains.annotations.Nullable method get(): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class D {
|
||||
// source: 'delegateMethodIsNonOverridable.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field x$delegate: kotlin.reflect.KProperty0
|
||||
inner (anonymous) class D$x$2$1
|
||||
public method <init>(): void
|
||||
public method getX(): int
|
||||
public static method getY$delegate(p0: D): java.lang.Object
|
||||
public method getY(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class DelegateMethodIsNonOverridableKt {
|
||||
// source: 'delegateMethodIsNonOverridable.kt'
|
||||
private final static field a: int
|
||||
private final static field b: int
|
||||
static method <clinit>(): void
|
||||
public final static method getA(): int
|
||||
public final static method getB(): int
|
||||
}
|
||||
Reference in New Issue
Block a user