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:
Alexander Udalov
2021-08-21 02:38:11 +02:00
committed by Alexander Udalov
parent 50508da156
commit 04c5bbdcf8
25 changed files with 565 additions and 48 deletions
@@ -13416,12 +13416,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnotherMutable.kt");
}
@Test
@TestMetadata("delegateToAnotherReflection.kt")
public void testDelegateToAnotherReflection() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnotherReflection.kt");
}
@Test
@TestMetadata("delegateToAnotherWithSideEffects.kt")
public void testDelegateToAnotherWithSideEffects() throws Exception {
@@ -13620,6 +13614,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/delegatedProperty/protectedVarWithPrivateSet.kt");
}
@Test
@TestMetadata("referenceEnclosingClassFieldInReceiver.kt")
public void testReferenceEnclosingClassFieldInReceiver() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver.kt");
}
@Test
@TestMetadata("referenceEnclosingClassFieldInReceiver2.kt")
public void testReferenceEnclosingClassFieldInReceiver2() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver2.kt");
}
@Test
@TestMetadata("setAsExtensionFun.kt")
public void testSetAsExtensionFun() throws Exception {
@@ -37865,6 +37871,28 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
public void testTopLevelProperty() throws Exception {
runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/topLevelProperty.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/reflection/properties/getDelegate/method")
@TestDataPath("$PROJECT_ROOT")
public class Method {
@Test
public void testAllFilesPresentInMethod() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/properties/getDelegate/method"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("delegateMethodIsNonOverridable.kt")
public void testDelegateMethodIsNonOverridable() throws Exception {
runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateMethodIsNonOverridable.kt");
}
@Test
@TestMetadata("delegateToAnother.kt")
public void testDelegateToAnother() throws Exception {
runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToAnother.kt");
}
}
}
@Nested
@@ -185,7 +185,8 @@ class LocalDeclarationsLowering(
override fun irGet(startOffset: Int, endOffset: Int, valueDeclaration: IrValueDeclaration): IrExpression? {
val field = classContext.capturedValueToField[valueDeclaration] ?: return null
val receiver = member.dispatchReceiverParameter!!
val receiver = member.dispatchReceiverParameter
?: error("No dispatch receiver parameter for ${member.render()}")
return IrGetFieldImpl(
startOffset, endOffset, field.symbol, field.type,
receiver = IrGetValueImpl(startOffset, endOffset, receiver.type, receiver.symbol)
@@ -416,6 +416,7 @@ private val jvmFilePhases = listOf(
typeOperatorLowering,
replaceKFunctionInvokeWithFunctionInvokePhase,
kotlinNothingValueExceptionPhase,
makePropertyDelegateMethodsStaticPhase,
renameFieldsPhase,
fakeInliningLocalVariablesLowering,
@@ -27,7 +27,9 @@ import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrFieldAccessExpression
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.classifierOrNull
import org.jetbrains.kotlin.ir.types.makeNotNull
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.load.java.JvmAbi
@@ -185,14 +187,15 @@ class JvmPropertiesLowering(private val backendContext: JvmBackendContext) : IrE
this.origin = origin
this.returnType = returnType
}.apply {
var index = 0
valueParameters = listOfNotNull(
declaration.getter?.dispatchReceiverParameter?.takeIf { !isStatic }?.let {
if (!isStatic) {
dispatchReceiverParameter = declaration.getter?.dispatchReceiverParameter?.let {
// Synthetic methods don't get generic type signatures anyway, so not exactly useful to preserve type parameters.
it.copyTo(this, type = it.type.eraseTypeParameters(), index = index++)
},
it.copyTo(this, type = it.type.eraseTypeParameters())
}
}
valueParameters = listOfNotNull(
declaration.getter?.extensionReceiverParameter?.let {
it.copyTo(this, type = it.type.eraseTypeParameters(), index = index)
it.copyTo(this, type = it.type.eraseTypeParameters(), index = 0)
}
)
parent = declaration.parent
@@ -0,0 +1,73 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.backend.jvm.lower
import org.jetbrains.kotlin.backend.common.FileLoweringPass
import org.jetbrains.kotlin.backend.common.ir.copyTo
import org.jetbrains.kotlin.backend.common.lower.VariableRemapper
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.backend.jvm.localDeclarationsPhase
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.load.java.JvmAbi
// This phase is needed to support correct generation of synthetic `$delegate` methods for optimized delegated properties, in the case
// when receiver of the optimized property reference is a field from an outer class.
//
// Since PropertyReferenceDelegationLowering runs before LocalDeclarationsLowering, fields for captured this (aka `this$0`) are not
// generated yet. And there's no other way to obtain the instance of the outer class on an arbitrary value of an inner class.
// However, we need `$delegate` methods to be static to be non-overridable (and public to be visible in reflection and external tools).
//
// So PropertyReferenceDelegationLowering generates `$delegate` methods for optimized property references as instance methods,
// and this phase, which runs _after_ LocalDeclarationsLowering, transforms them to static methods.
internal val makePropertyDelegateMethodsStaticPhase = makeIrFilePhase(
::MakePropertyDelegateMethodsStaticLowering,
name = "MakePropertyDelegateMethodsStatic",
description = "Make `\$delegate` methods for optimized delegated properties static",
prerequisite = setOf(propertyReferenceDelegationPhase, localDeclarationsPhase)
)
private class MakePropertyDelegateMethodsStaticLowering(val context: JvmBackendContext) : IrElementTransformerVoid(), FileLoweringPass {
override fun lower(irFile: IrFile) {
irFile.transform(this, null)
}
override fun visitSimpleFunction(declaration: IrSimpleFunction): IrStatement {
if (!declaration.isSyntheticDelegateMethod()) return super.visitSimpleFunction(declaration)
val oldParameter = declaration.dispatchReceiverParameter ?: return super.visitSimpleFunction(declaration)
val newParameter = oldParameter.copyTo(declaration, index = 0)
return declaration.apply {
valueParameters =
listOf(newParameter) + valueParameters.map { it.copyTo(this, index = it.index + 1) }
dispatchReceiverParameter = null
body = body?.transform(VariableRemapper(mapOf(oldParameter to newParameter)), null)
}
}
override fun visitCall(expression: IrCall): IrExpression {
// There should be no calls to synthetic `$delegate` methods because they aren't accessible in the source code, and we don't
// generate any calls in the IR. Otherwise we would need to remap arguments in those calls.
if (expression.symbol.owner.isSyntheticDelegateMethod()) {
error(
"`\$delegate` method should not be called. Please either remove the call, or support remapping of dispatch receiver " +
"in MakePropertyDelegateMethodsStaticLowering: ${expression.symbol.owner.render()}"
)
}
return super.visitCall(expression)
}
private fun IrSimpleFunction.isSyntheticDelegateMethod(): Boolean =
origin == IrDeclarationOrigin.PROPERTY_DELEGATE && name.asString().endsWith(JvmAbi.DELEGATED_PROPERTY_NAME_SUFFIX)
}
@@ -151,11 +151,11 @@ private class PropertyReferenceDelegationTransformer(val context: JvmBackendCont
getter?.apply { body = accessorBody(delegate, backingField ?: receiver?.inline(originalThis, dispatchReceiverParameter)) }
setter?.apply { body = accessorBody(delegate, backingField ?: receiver?.inline(originalThis, dispatchReceiverParameter)) }
// The `$delegate` method is generated as instance method here, see MakePropertyDelegateMethodsStaticLowering.
val delegateMethod = context.createSyntheticMethodForPropertyDelegate(this).apply {
body = context.createJvmIrBuilder(symbol).run {
val propertyOwner = if (getter?.dispatchReceiverParameter != null) valueParameters[0] else null
val boundReceiver = backingField?.let { irGetField(propertyOwner?.let(::irGet), it) }
?: receiver?.inline(originalThis, propertyOwner)
val boundReceiver = backingField?.let { irGetField(dispatchReceiverParameter?.let(::irGet), it) }
?: receiver?.inline(originalThis, dispatchReceiverParameter)
irExprBody(with(delegate) {
val origin = PropertyReferenceLowering.REFLECTED_PROPERTY_REFERENCE
IrPropertyReferenceImpl(startOffset, endOffset, type, symbol, typeArgumentsCount, field, getter, setter, origin)
@@ -0,0 +1,23 @@
// WITH_RUNTIME
interface I {
var z: String
}
class X {
var p: String = "Fail"
}
class A {
val x = X()
val y = object : I {
override var z: String by x::p
}
}
fun box(): String {
val a = A()
a.y.z = "OK"
return a.y.z
}
@@ -0,0 +1,25 @@
// WITH_RUNTIME
interface I {
var z: String
}
class X {
var p: String = "Fail"
}
class A {
val x = X()
inner class Y : I {
override var z: String by x::p
}
val y = Y()
}
fun box(): String {
val a = A()
a.y.z = "OK"
return a.y.z
}
@@ -0,0 +1,34 @@
// TARGET_BACKEND: JVM
// WITH_REFLECT
import kotlin.reflect.*
import kotlin.reflect.jvm.isAccessible
val a = 1
val b = 2
fun KProperty0<*>.test(): String =
(apply { isAccessible = true }.getDelegate() as KProperty<*>).name
open class C {
open val x by run { ::a }
open val y by ::a
val xc = ::x.test()
val yc = ::y.test()
}
class D : C() {
override val x by run { ::b }
override val y by ::b
val xd = ::x.test()
val yd = ::y.test()
}
fun box(): String {
val result = D().run { "$xc $yc $xd $yd" }
if (result != "a a b b") return "Fail: $result"
return "OK"
}
@@ -11,6 +11,8 @@ class C(var x: Int) {
class D(val c: C) {
var y by c::x
var C.w by C::x
var Int.q by Int::x
}
var x = 1
@@ -40,6 +42,9 @@ fun <T> KMutableProperty1<T, Int>.test(receiver: T) =
fun <T> KMutableProperty1<T, Int>.test(receiver: T, receiver2: T) =
test({ getDelegate(receiver) as KMutableProperty1<T, Int> }, { get(receiver2) }, { set(receiver2, it) })
fun <R1, R2> KMutableProperty2<R1, R2, Int>.test(receiver1: R1, receiver2: R2) =
test({ getDelegate(receiver1, receiver2) as KMutableProperty1<R2, Int> }, { get(receiver2) }, { set(receiver2, it) })
fun box(): String {
C::y.test(C(100), C(1))
C::z.test(C(1))
@@ -47,5 +52,12 @@ fun box(): String {
::y.test()
::z.test()
Int::y.test({ getExtensionDelegate() as KMutableProperty1<Int, Int> }, { get(100) }, { set(100, it) })
val w = D::class.members.single { it.name == "w" } as KMutableProperty2<D, C, Int>
w.test(D(C(100)), C(1))
val q = D::class.members.single { it.name == "q" } as KMutableProperty2<D, Int, Int>
q.test({ getExtensionDelegate(D(C(100))) as KMutableProperty1<Int, Int> }, { get(100) }, { set(100, it) })
return "OK"
}
@@ -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
}
@@ -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
}
@@ -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
}
@@ -35,11 +35,11 @@ fun local() {
// 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
// 12 public( static)? get[XYZ]m?\$delegate
// JVM_TEMPLATES
// Not optimized, references created as classes and stored in fields:
// 16 extends kotlin/jvm/internal/MutablePropertyReference[0-2]Impl
// 12 private final( static)? Lkotlin/reflect/KMutableProperty[0-2]; [xyz]m?\$delegate
// 4 LOCALVARIABLE [xyz]m? Lkotlin/reflect/KMutableProperty[0-2];
// 0 static get[XYZ]m?\$delegate
// 0 get[XYZ]m?\$delegate
@@ -13308,12 +13308,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnotherMutable.kt");
}
@Test
@TestMetadata("delegateToAnotherReflection.kt")
public void testDelegateToAnotherReflection() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnotherReflection.kt");
}
@Test
@TestMetadata("delegateToAnotherWithSideEffects.kt")
public void testDelegateToAnotherWithSideEffects() throws Exception {
@@ -13512,6 +13506,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/delegatedProperty/protectedVarWithPrivateSet.kt");
}
@Test
@TestMetadata("referenceEnclosingClassFieldInReceiver.kt")
public void testReferenceEnclosingClassFieldInReceiver() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver.kt");
}
@Test
@TestMetadata("referenceEnclosingClassFieldInReceiver2.kt")
public void testReferenceEnclosingClassFieldInReceiver2() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver2.kt");
}
@Test
@TestMetadata("setAsExtensionFun.kt")
public void testSetAsExtensionFun() throws Exception {
@@ -37685,6 +37691,28 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testTopLevelProperty() throws Exception {
runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/topLevelProperty.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/reflection/properties/getDelegate/method")
@TestDataPath("$PROJECT_ROOT")
public class Method {
@Test
public void testAllFilesPresentInMethod() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/properties/getDelegate/method"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@Test
@TestMetadata("delegateMethodIsNonOverridable.kt")
public void testDelegateMethodIsNonOverridable() throws Exception {
runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateMethodIsNonOverridable.kt");
}
@Test
@TestMetadata("delegateToAnother.kt")
public void testDelegateToAnother() throws Exception {
runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToAnother.kt");
}
}
}
@Nested
@@ -91,12 +91,6 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
runTest("compiler/testData/codegen/bytecodeListing/defaultImpls.kt");
}
@Test
@TestMetadata("delegatedPropertiesInCompanionObject.kt")
public void testDelegatedPropertiesInCompanionObject() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/delegatedPropertiesInCompanionObject.kt");
}
@Test
@TestMetadata("delegationToJavaInterfaceWithWildcardType.kt")
public void testDelegationToJavaInterfaceWithWildcardType() throws Exception {
@@ -1009,6 +1003,28 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
}
}
@Nested
@TestMetadata("compiler/testData/codegen/bytecodeListing/delegatedProperty")
@TestDataPath("$PROJECT_ROOT")
public class DelegatedProperty {
@Test
public void testAllFilesPresentInDelegatedProperty() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/delegatedProperty"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@Test
@TestMetadata("delegateMethodIsNonOverridable.kt")
public void testDelegateMethodIsNonOverridable() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/delegatedProperty/delegateMethodIsNonOverridable.kt");
}
@Test
@TestMetadata("delegatedPropertiesInCompanionObject.kt")
public void testDelegatedPropertiesInCompanionObject() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/delegatedProperty/delegatedPropertiesInCompanionObject.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/bytecodeListing/deprecated")
@TestDataPath("$PROJECT_ROOT")
@@ -13416,12 +13416,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnotherMutable.kt");
}
@Test
@TestMetadata("delegateToAnotherReflection.kt")
public void testDelegateToAnotherReflection() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnotherReflection.kt");
}
@Test
@TestMetadata("delegateToAnotherWithSideEffects.kt")
public void testDelegateToAnotherWithSideEffects() throws Exception {
@@ -13620,6 +13614,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/delegatedProperty/protectedVarWithPrivateSet.kt");
}
@Test
@TestMetadata("referenceEnclosingClassFieldInReceiver.kt")
public void testReferenceEnclosingClassFieldInReceiver() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver.kt");
}
@Test
@TestMetadata("referenceEnclosingClassFieldInReceiver2.kt")
public void testReferenceEnclosingClassFieldInReceiver2() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver2.kt");
}
@Test
@TestMetadata("setAsExtensionFun.kt")
public void testSetAsExtensionFun() throws Exception {
@@ -37865,6 +37871,28 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
public void testTopLevelProperty() throws Exception {
runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/topLevelProperty.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/reflection/properties/getDelegate/method")
@TestDataPath("$PROJECT_ROOT")
public class Method {
@Test
public void testAllFilesPresentInMethod() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/properties/getDelegate/method"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("delegateMethodIsNonOverridable.kt")
public void testDelegateMethodIsNonOverridable() throws Exception {
runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateMethodIsNonOverridable.kt");
}
@Test
@TestMetadata("delegateToAnother.kt")
public void testDelegateToAnother() throws Exception {
runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToAnother.kt");
}
}
}
@Nested
@@ -91,12 +91,6 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
runTest("compiler/testData/codegen/bytecodeListing/defaultImpls.kt");
}
@Test
@TestMetadata("delegatedPropertiesInCompanionObject.kt")
public void testDelegatedPropertiesInCompanionObject() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/delegatedPropertiesInCompanionObject.kt");
}
@Test
@TestMetadata("delegationToJavaInterfaceWithWildcardType.kt")
public void testDelegationToJavaInterfaceWithWildcardType() throws Exception {
@@ -1057,6 +1051,28 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
}
}
@Nested
@TestMetadata("compiler/testData/codegen/bytecodeListing/delegatedProperty")
@TestDataPath("$PROJECT_ROOT")
public class DelegatedProperty {
@Test
public void testAllFilesPresentInDelegatedProperty() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/delegatedProperty"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("delegateMethodIsNonOverridable.kt")
public void testDelegateMethodIsNonOverridable() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/delegatedProperty/delegateMethodIsNonOverridable.kt");
}
@Test
@TestMetadata("delegatedPropertiesInCompanionObject.kt")
public void testDelegatedPropertiesInCompanionObject() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/delegatedProperty/delegatedPropertiesInCompanionObject.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/bytecodeListing/deprecated")
@TestDataPath("$PROJECT_ROOT")
@@ -10823,11 +10823,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnotherMutable.kt");
}
@TestMetadata("delegateToAnotherReflection.kt")
public void testDelegateToAnotherReflection() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnotherReflection.kt");
}
@TestMetadata("delegateToAnotherWithSideEffects.kt")
public void testDelegateToAnotherWithSideEffects() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnotherWithSideEffects.kt");
@@ -10983,6 +10978,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/delegatedProperty/protectedVarWithPrivateSet.kt");
}
@TestMetadata("referenceEnclosingClassFieldInReceiver.kt")
public void testReferenceEnclosingClassFieldInReceiver() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver.kt");
}
@TestMetadata("referenceEnclosingClassFieldInReceiver2.kt")
public void testReferenceEnclosingClassFieldInReceiver2() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver2.kt");
}
@TestMetadata("setAsExtensionFun.kt")
public void testSetAsExtensionFun() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/setAsExtensionFun.kt");
@@ -30016,6 +30021,29 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testTopLevelProperty() throws Exception {
runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/topLevelProperty.kt");
}
@TestMetadata("compiler/testData/codegen/box/reflection/properties/getDelegate/method")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Method extends AbstractLightAnalysisModeTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInMethod() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/properties/getDelegate/method"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("delegateMethodIsNonOverridable.kt")
public void testDelegateMethodIsNonOverridable() throws Exception {
runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateMethodIsNonOverridable.kt");
}
@TestMetadata("delegateToAnother.kt")
public void testDelegateToAnother() throws Exception {
runTest("compiler/testData/codegen/box/reflection/properties/getDelegate/method/delegateToAnother.kt");
}
}
}
@TestMetadata("compiler/testData/codegen/box/reflection/properties/jvmField")
@@ -9762,6 +9762,16 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/delegatedProperty/protectedVarWithPrivateSet.kt");
}
@TestMetadata("referenceEnclosingClassFieldInReceiver.kt")
public void testReferenceEnclosingClassFieldInReceiver() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver.kt");
}
@TestMetadata("referenceEnclosingClassFieldInReceiver2.kt")
public void testReferenceEnclosingClassFieldInReceiver2() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver2.kt");
}
@TestMetadata("setAsExtensionFun.kt")
public void testSetAsExtensionFun() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/setAsExtensionFun.kt");
@@ -25681,6 +25691,19 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
public void testAllFilesPresentInGetDelegate() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/properties/getDelegate"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
@TestMetadata("compiler/testData/codegen/box/reflection/properties/getDelegate/method")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Method extends AbstractIrJsCodegenBoxES6Test {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
}
public void testAllFilesPresentInMethod() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/properties/getDelegate/method"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
}
}
@TestMetadata("compiler/testData/codegen/box/reflection/properties/jvmField")
@@ -9168,6 +9168,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/delegatedProperty/protectedVarWithPrivateSet.kt");
}
@TestMetadata("referenceEnclosingClassFieldInReceiver.kt")
public void testReferenceEnclosingClassFieldInReceiver() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver.kt");
}
@TestMetadata("referenceEnclosingClassFieldInReceiver2.kt")
public void testReferenceEnclosingClassFieldInReceiver2() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver2.kt");
}
@TestMetadata("setAsExtensionFun.kt")
public void testSetAsExtensionFun() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/setAsExtensionFun.kt");
@@ -25087,6 +25097,19 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
public void testAllFilesPresentInGetDelegate() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/properties/getDelegate"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@TestMetadata("compiler/testData/codegen/box/reflection/properties/getDelegate/method")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Method extends AbstractIrJsCodegenBoxTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
}
public void testAllFilesPresentInMethod() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/properties/getDelegate/method"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
}
}
@TestMetadata("compiler/testData/codegen/box/reflection/properties/jvmField")
@@ -9168,6 +9168,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/delegatedProperty/protectedVarWithPrivateSet.kt");
}
@TestMetadata("referenceEnclosingClassFieldInReceiver.kt")
public void testReferenceEnclosingClassFieldInReceiver() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver.kt");
}
@TestMetadata("referenceEnclosingClassFieldInReceiver2.kt")
public void testReferenceEnclosingClassFieldInReceiver2() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/referenceEnclosingClassFieldInReceiver2.kt");
}
@TestMetadata("setAsExtensionFun.kt")
public void testSetAsExtensionFun() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/setAsExtensionFun.kt");
@@ -25047,6 +25057,19 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
public void testAllFilesPresentInGetDelegate() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/properties/getDelegate"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
}
@TestMetadata("compiler/testData/codegen/box/reflection/properties/getDelegate/method")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Method extends AbstractJsCodegenBoxTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
}
public void testAllFilesPresentInMethod() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/properties/getDelegate/method"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
}
}
}
@TestMetadata("compiler/testData/codegen/box/reflection/properties/jvmField")