diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index f7da1f38c34..97454315733 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -2153,7 +2153,8 @@ public class ExpressionCodegen extends KtVisitor impleme return StackValue.property( propertyDescriptor, backingFieldOwner, typeMapper.mapType(isDelegatedProperty && forceField ? delegateType : propertyDescriptor.getOriginal().getType()), - isStaticBackingField, fieldName, callableGetter, callableSetter, receiver, this, resolvedCall, skipLateinitAssertion + isStaticBackingField, fieldName, callableGetter, callableSetter, receiver, this, resolvedCall, skipLateinitAssertion, + isDelegatedProperty && forceField ? delegateType : null ); } @@ -2169,7 +2170,7 @@ public class ExpressionCodegen extends KtVisitor impleme CallableMethod callableSetter = setMethod != null ? typeMapper.mapToCallableMethod(context.accessibleDescriptor(setMethod, null), false) : null; return StackValue.property(propertyDescriptor, null, type, false, null, callableGetter, callableSetter, receiver, this, - null, false); + null, false, null); } @Override diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java index 21a0af66b60..722a36211d2 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java @@ -510,19 +510,29 @@ public abstract class MemberCodegen provideDelegateResolvedCall = bindingContext.get(PROVIDE_DELEGATE_RESOLVED_CALL, propertyDescriptor); - if (provideDelegateResolvedCall == null) { + if (property.getDelegateExpression() == null) { propValue.store(codegen.gen(initializer), codegen.v); - return; } + else { + StackValue.Property delegate = propValue.getDelegateOrNull(); + assert delegate != null : "No delegate for delegated property: " + propertyDescriptor; - StackValue provideDelegateReceiver = codegen.gen(initializer); + ResolvedCall provideDelegateResolvedCall = + bindingContext.get(PROVIDE_DELEGATE_RESOLVED_CALL, propertyDescriptor); - StackValue delegateValue = PropertyCodegen.invokeDelegatedPropertyConventionMethod( - codegen, provideDelegateResolvedCall, provideDelegateReceiver, propertyDescriptor - ); + if (provideDelegateResolvedCall == null) { + delegate.store(codegen.gen(initializer), codegen.v); + } + else { + StackValue provideDelegateReceiver = codegen.gen(initializer); - propValue.store(delegateValue, codegen.v); + StackValue delegateValue = PropertyCodegen.invokeDelegatedPropertyConventionMethod( + codegen, provideDelegateResolvedCall, provideDelegateReceiver, propertyDescriptor + ); + + delegate.store(delegateValue, codegen.v); + } + } } // Public accessible for serialization plugin to check whether call to initializeProperty(..) is legal. diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java index 2405a09343e..0cf157089a1 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java @@ -605,8 +605,10 @@ public class PropertyCodegen { assert resolvedCall != null : "Resolve call should be recorded for delegate call " + signature.toString(); PropertyDescriptor propertyDescriptor = propertyAccessorDescriptor.getCorrespondingProperty(); - StackValue.Property receiver = codegen.intermediateValueForProperty(propertyDescriptor, true, null, StackValue.LOCAL_0); - StackValue lastValue = invokeDelegatedPropertyConventionMethod(codegen, resolvedCall, receiver, propertyDescriptor); + StackValue.Property property = codegen.intermediateValueForProperty(propertyDescriptor, true, null, StackValue.LOCAL_0); + StackValue.Property delegate = property.getDelegateOrNull(); + assert delegate != null : "No delegate for delegated property: " + propertyDescriptor; + StackValue lastValue = invokeDelegatedPropertyConventionMethod(codegen, resolvedCall, delegate, propertyDescriptor); Type asmType = signature.getReturnType(); lastValue.put(asmType, v); v.areturn(asmType); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java index 639fe9bf162..7310cabb600 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java @@ -363,10 +363,11 @@ public abstract class StackValue { @NotNull StackValue receiver, @NotNull ExpressionCodegen codegen, @Nullable ResolvedCall resolvedCall, - boolean skipLateinitAssertion + boolean skipLateinitAssertion, + @Nullable KotlinType delegateKotlinType ) { return new Property(descriptor, backingFieldOwner, getter, setter, isStaticBackingField, fieldName, type, receiver, codegen, - resolvedCall, skipLateinitAssertion); + resolvedCall, skipLateinitAssertion, delegateKotlinType); } @NotNull @@ -1460,7 +1461,6 @@ public abstract class StackValue { } } - public static class Field extends StackValueWithSimpleReceiver { public final Type owner; public final String name; @@ -1508,12 +1508,13 @@ public abstract class StackValue { private final ExpressionCodegen codegen; private final ResolvedCall resolvedCall; private final boolean skipLateinitAssertion; + private final KotlinType delegateKotlinType; public Property( @NotNull PropertyDescriptor descriptor, @Nullable Type backingFieldOwner, @Nullable CallableMethod getter, @Nullable CallableMethod setter, boolean isStaticBackingField, @Nullable String fieldName, @NotNull Type type, @NotNull StackValue receiver, @NotNull ExpressionCodegen codegen, @Nullable ResolvedCall resolvedCall, - boolean skipLateinitAssertion + boolean skipLateinitAssertion, @Nullable KotlinType delegateKotlinType ) { super(type, descriptor.getType(), isStatic(isStaticBackingField, getter), isStatic(isStaticBackingField, setter), receiver, true); this.backingFieldOwner = backingFieldOwner; @@ -1524,6 +1525,44 @@ public abstract class StackValue { this.codegen = codegen; this.resolvedCall = resolvedCall; this.skipLateinitAssertion = skipLateinitAssertion; + this.delegateKotlinType = delegateKotlinType; + } + + private static class DelegatePropertyConstructorMarker { + private DelegatePropertyConstructorMarker() {} + public static final DelegatePropertyConstructorMarker MARKER = new DelegatePropertyConstructorMarker(); + } + + /** + * Given a delegating property, create a "property" corresponding to the underlying delegate itself. + * This will take care of backing fields, accessors, and other such stuff. + * Note that we just replace kotlinType with the delegateKotlinType + * (so that type coercion will work properly), + * and delegateKotlinType with null + * (so that the resulting property has no underlying delegate of its own). + * + * @param delegating delegating property + * @param marker intent marker + */ + @SuppressWarnings("unused") + private Property(@NotNull Property delegating, @NotNull DelegatePropertyConstructorMarker marker) { + super(delegating.type, delegating.delegateKotlinType, + delegating.isStaticPut, delegating.isStaticStore, delegating.receiver, true); + + this.backingFieldOwner = delegating.backingFieldOwner; + this.getter = delegating.getter; + this.setter = delegating.setter; + this.descriptor = delegating.descriptor; + this.fieldName = delegating.fieldName; + this.codegen = delegating.codegen; + this.resolvedCall = delegating.resolvedCall; + this.skipLateinitAssertion = delegating.skipLateinitAssertion; + this.delegateKotlinType = null; + } + + public Property getDelegateOrNull() { + if (delegateKotlinType == null) return null; + return new Property(this, DelegatePropertyConstructorMarker.MARKER); } @Override diff --git a/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClass.kt b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClass.kt new file mode 100644 index 00000000000..311e5a663d6 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClass.kt @@ -0,0 +1,36 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +class Foo { + var a: Int = 42 + var d by Delegate(0) +} + +var setterInvoked = 0 + +inline class Delegate(val default: Int) { + + operator fun getValue(thisRef: Any?, prop: Any?) = + (thisRef as? Foo)?.a ?: default + + operator fun setValue(thisRef: Any?, prop: Any?, newValue: Int) { + setterInvoked++ + if (thisRef is Foo) { + thisRef.a = newValue + } + } +} + + +fun box(): String { + val x = Foo() + if (x.d != 42) throw AssertionError() + + x.d = 1234 + if (x.d != 1234) throw AssertionError() + if (x.a != 1234) throw AssertionError() + + if (setterInvoked != 1) throw AssertionError() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClassWithProvideDelegate.kt b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClassWithProvideDelegate.kt new file mode 100644 index 00000000000..a3d50be7f1a --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClassWithProvideDelegate.kt @@ -0,0 +1,45 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +class Foo { + var a: Int = 42 + var d by DelegateFactory(0) +} + +var provideDelegateInvoked = 0 +var setterInvoked = 0 + +inline class DelegateFactory(val default: Int) { + operator fun provideDelegate(thisRef: Any?, prop: Any?): Delegate { + provideDelegateInvoked++ + return Delegate(default) + } +} + +inline class Delegate(val default: Int) { + + operator fun getValue(thisRef: Any?, prop: Any?) = + (thisRef as? Foo)?.a ?: default + + operator fun setValue(thisRef: Any?, prop: Any?, newValue: Int) { + setterInvoked++ + if (thisRef is Foo) { + thisRef.a = newValue + } + } +} + + +fun box(): String { + val x = Foo() + if (x.d != 42) throw AssertionError() + + x.d = 1234 + if (x.d != 1234) throw AssertionError() + if (x.a != 1234) throw AssertionError() + + if (setterInvoked != 1) throw AssertionError() + if (provideDelegateInvoked != 1) throw AssertionError() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateCompanionVarToInlineClass.kt b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateCompanionVarToInlineClass.kt new file mode 100644 index 00000000000..1989cbdb0e8 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateCompanionVarToInlineClass.kt @@ -0,0 +1,34 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +class Foo { + companion object { + var a: Int = 42 + var d by Delegate(0) + } +} + +var setterInvoked = 0 + +inline class Delegate(val ignored: Int) { + + operator fun getValue(thisRef: Any?, prop: Any?) = Foo.a + + operator fun setValue(thisRef: Any?, prop: Any?, newValue: Int) { + setterInvoked++ + Foo.a = newValue + } +} + + +fun box(): String { + if (Foo.d != 42) throw AssertionError() + + Foo.d = 1234 + if (Foo.d != 1234) throw AssertionError() + if (Foo.a != 1234) throw AssertionError() + + if (setterInvoked != 1) throw AssertionError() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateJvmStaticCompanionVarToInlineClass.kt b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateJvmStaticCompanionVarToInlineClass.kt new file mode 100644 index 00000000000..31cd91e2950 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateJvmStaticCompanionVarToInlineClass.kt @@ -0,0 +1,35 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR, JS, JS_IR +// WITH_RUNTIME + +class Foo { + companion object { + var a: Int = 42 + @JvmStatic var d by Delegate(0) + } +} + +var setterInvoked = 0 + +inline class Delegate(val ignored: Int) { + + operator fun getValue(thisRef: Any?, prop: Any?) = Foo.a + + operator fun setValue(thisRef: Any?, prop: Any?, newValue: Int) { + setterInvoked++ + Foo.a = newValue + } +} + + +fun box(): String { + if (Foo.d != 42) throw AssertionError() + + Foo.d = 1234 + if (Foo.d != 1234) throw AssertionError() + if (Foo.a != 1234) throw AssertionError() + + if (setterInvoked != 1) throw AssertionError() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateObjectVarToInlineClass.kt b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateObjectVarToInlineClass.kt new file mode 100644 index 00000000000..35414aa670d --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateObjectVarToInlineClass.kt @@ -0,0 +1,32 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +object Foo { + var a: Int = 42 + var d by Delegate(0) +} + +var setterInvoked = 0 + +inline class Delegate(val ignored: Int) { + + operator fun getValue(thisRef: Any?, prop: Any?) = Foo.a + + operator fun setValue(thisRef: Any?, prop: Any?, newValue: Int) { + setterInvoked++ + Foo.a = newValue + } +} + + +fun box(): String { + if (Foo.d != 42) throw AssertionError() + + Foo.d = 1234 + if (Foo.d != 1234) throw AssertionError() + if (Foo.a != 1234) throw AssertionError() + + if (setterInvoked != 1) throw AssertionError() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateTopLevelVarToInlineClass.kt b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateTopLevelVarToInlineClass.kt new file mode 100644 index 00000000000..ba600838a3e --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateTopLevelVarToInlineClass.kt @@ -0,0 +1,30 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +var setterInvoked = 0 +var backing = 42 + +inline class Delegate(val ignored: Int) { + + operator fun getValue(thisRef: Any?, prop: Any?) = + backing + + operator fun setValue(thisRef: Any?, prop: Any?, newValue: Int) { + setterInvoked++ + backing = newValue + } +} + +var topLevelD by Delegate(0) + +fun box(): String { + if (topLevelD != 42) AssertionError() + + topLevelD = 1234 + if (topLevelD != 1234) throw AssertionError() + if (backing != 1234) throw AssertionError() + + if (setterInvoked != 1) throw AssertionError() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt new file mode 100644 index 00000000000..61e73f3642f --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt @@ -0,0 +1,24 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME + +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty + +class Foo { + val a: Int = 42 + val b by Delegate(0) +} + +inline class Delegate(val ignored: Int): ReadOnlyProperty { + override fun getValue(thisRef: Foo, property: KProperty<*>): Int { + return thisRef.a + } +} + +fun box(): String { + val x = Foo() + if (x.b != 42) throw AssertionError() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/noBoxingUnboxingInAccessorsForDelegatedPropertyWithInlineClassDelegate.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/noBoxingUnboxingInAccessorsForDelegatedPropertyWithInlineClassDelegate.kt new file mode 100644 index 00000000000..56a8a77ecd6 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/noBoxingUnboxingInAccessorsForDelegatedPropertyWithInlineClassDelegate.kt @@ -0,0 +1,33 @@ +// !LANGUAGE: +InlineClasses +// FILE: Foo.kt +class Foo { + var a: Int = 42 + var d by DelegateFactory(0) +} + +// FILE: delegates.kt +inline class DelegateFactory(val default: Int) { + operator fun provideDelegate(thisRef: Any?, prop: Any?) = Delegate(default) +} + +inline class Delegate(val default: Int) { + + operator fun getValue(thisRef: Any?, prop: Any?) = + (thisRef as? Foo)?.a ?: default + + operator fun setValue(thisRef: Any?, prop: Any?, newValue: Int) { + if (thisRef is Foo) { + thisRef.a = newValue + } + } +} + + +// @Foo.class: +// 0 DelegateFactory\.box +// 0 DelegateFactory\.unbox +// 0 Delegate\.box +// 0 Delegate\.unbox +// 1 INVOKESTATIC DelegateFactory\.provideDelegate-impl \(ILjava/lang/Object;Ljava/lang/Object;\)I +// 1 INVOKESTATIC Delegate\.getValue-impl \(ILjava/lang/Object;Ljava/lang/Object;\)I +// 1 INVOKESTATIC Delegate\.setValue-impl \(ILjava/lang/Object;Ljava/lang/Object;I\)V \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 743dc5ce465..346a3abca5b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -12305,6 +12305,54 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/overriddenDefaultInterfaceMethodCall.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PropertyDelegation extends AbstractBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInPropertyDelegation() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/propertyDelegation"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("delegateClassVarToInlineClass.kt") + public void testDelegateClassVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClass.kt"); + } + + @TestMetadata("delegateClassVarToInlineClassWithProvideDelegate.kt") + public void testDelegateClassVarToInlineClassWithProvideDelegate() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClassWithProvideDelegate.kt"); + } + + @TestMetadata("delegateCompanionVarToInlineClass.kt") + public void testDelegateCompanionVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateCompanionVarToInlineClass.kt"); + } + + @TestMetadata("delegateJvmStaticCompanionVarToInlineClass.kt") + public void testDelegateJvmStaticCompanionVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateJvmStaticCompanionVarToInlineClass.kt"); + } + + @TestMetadata("delegateObjectVarToInlineClass.kt") + public void testDelegateObjectVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateObjectVarToInlineClass.kt"); + } + + @TestMetadata("delegateTopLevelVarToInlineClass.kt") + public void testDelegateTopLevelVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateTopLevelVarToInlineClass.kt"); + } + + @TestMetadata("kt27070.kt") + public void testKt27070() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index e98933356df..f33e7a94d5f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -2166,6 +2166,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/noBoxingOperationsOnNonTrivialSpread.kt"); } + @TestMetadata("noBoxingUnboxingInAccessorsForDelegatedPropertyWithInlineClassDelegate.kt") + public void testNoBoxingUnboxingInAccessorsForDelegatedPropertyWithInlineClassDelegate() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/noBoxingUnboxingInAccessorsForDelegatedPropertyWithInlineClassDelegate.kt"); + } + @TestMetadata("nonOverridingMethodsAreCalledByInlineClass.kt") public void testNonOverridingMethodsAreCalledByInlineClass() throws Exception { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/nonOverridingMethodsAreCalledByInlineClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 21c5e15fc8b..e1fe619948a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -12305,6 +12305,54 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/overriddenDefaultInterfaceMethodCall.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PropertyDelegation extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInPropertyDelegation() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/propertyDelegation"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("delegateClassVarToInlineClass.kt") + public void testDelegateClassVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClass.kt"); + } + + @TestMetadata("delegateClassVarToInlineClassWithProvideDelegate.kt") + public void testDelegateClassVarToInlineClassWithProvideDelegate() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClassWithProvideDelegate.kt"); + } + + @TestMetadata("delegateCompanionVarToInlineClass.kt") + public void testDelegateCompanionVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateCompanionVarToInlineClass.kt"); + } + + @TestMetadata("delegateJvmStaticCompanionVarToInlineClass.kt") + public void testDelegateJvmStaticCompanionVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateJvmStaticCompanionVarToInlineClass.kt"); + } + + @TestMetadata("delegateObjectVarToInlineClass.kt") + public void testDelegateObjectVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateObjectVarToInlineClass.kt"); + } + + @TestMetadata("delegateTopLevelVarToInlineClass.kt") + public void testDelegateTopLevelVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateTopLevelVarToInlineClass.kt"); + } + + @TestMetadata("kt27070.kt") + public void testKt27070() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 8f3baf569b9..f458bbc78e2 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -12310,6 +12310,54 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/overriddenDefaultInterfaceMethodCall.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PropertyDelegation extends AbstractIrBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInPropertyDelegation() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/propertyDelegation"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); + } + + @TestMetadata("delegateClassVarToInlineClass.kt") + public void testDelegateClassVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClass.kt"); + } + + @TestMetadata("delegateClassVarToInlineClassWithProvideDelegate.kt") + public void testDelegateClassVarToInlineClassWithProvideDelegate() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClassWithProvideDelegate.kt"); + } + + @TestMetadata("delegateCompanionVarToInlineClass.kt") + public void testDelegateCompanionVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateCompanionVarToInlineClass.kt"); + } + + @TestMetadata("delegateJvmStaticCompanionVarToInlineClass.kt") + public void testDelegateJvmStaticCompanionVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateJvmStaticCompanionVarToInlineClass.kt"); + } + + @TestMetadata("delegateObjectVarToInlineClass.kt") + public void testDelegateObjectVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateObjectVarToInlineClass.kt"); + } + + @TestMetadata("delegateTopLevelVarToInlineClass.kt") + public void testDelegateTopLevelVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateTopLevelVarToInlineClass.kt"); + } + + @TestMetadata("kt27070.kt") + public void testKt27070() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested") diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java index 739eabe29f6..25b33b4ea79 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java @@ -10845,6 +10845,54 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/overriddenDefaultInterfaceMethodCall.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PropertyDelegation extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInPropertyDelegation() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/propertyDelegation"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); + } + + @TestMetadata("delegateClassVarToInlineClass.kt") + public void testDelegateClassVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClass.kt"); + } + + @TestMetadata("delegateClassVarToInlineClassWithProvideDelegate.kt") + public void testDelegateClassVarToInlineClassWithProvideDelegate() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClassWithProvideDelegate.kt"); + } + + @TestMetadata("delegateCompanionVarToInlineClass.kt") + public void testDelegateCompanionVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateCompanionVarToInlineClass.kt"); + } + + @TestMetadata("delegateJvmStaticCompanionVarToInlineClass.kt") + public void testDelegateJvmStaticCompanionVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateJvmStaticCompanionVarToInlineClass.kt"); + } + + @TestMetadata("delegateObjectVarToInlineClass.kt") + public void testDelegateObjectVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateObjectVarToInlineClass.kt"); + } + + @TestMetadata("delegateTopLevelVarToInlineClass.kt") + public void testDelegateTopLevelVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateTopLevelVarToInlineClass.kt"); + } + + @TestMetadata("kt27070.kt") + public void testKt27070() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested") diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 0928063d529..e3f952d3e33 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -11890,6 +11890,54 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/overriddenDefaultInterfaceMethodCall.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PropertyDelegation extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInPropertyDelegation() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/propertyDelegation"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); + } + + @TestMetadata("delegateClassVarToInlineClass.kt") + public void testDelegateClassVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClass.kt"); + } + + @TestMetadata("delegateClassVarToInlineClassWithProvideDelegate.kt") + public void testDelegateClassVarToInlineClassWithProvideDelegate() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateClassVarToInlineClassWithProvideDelegate.kt"); + } + + @TestMetadata("delegateCompanionVarToInlineClass.kt") + public void testDelegateCompanionVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateCompanionVarToInlineClass.kt"); + } + + @TestMetadata("delegateJvmStaticCompanionVarToInlineClass.kt") + public void testDelegateJvmStaticCompanionVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateJvmStaticCompanionVarToInlineClass.kt"); + } + + @TestMetadata("delegateObjectVarToInlineClass.kt") + public void testDelegateObjectVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateObjectVarToInlineClass.kt"); + } + + @TestMetadata("delegateTopLevelVarToInlineClass.kt") + public void testDelegateTopLevelVarToInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/delegateTopLevelVarToInlineClass.kt"); + } + + @TestMetadata("kt27070.kt") + public void testKt27070() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/propertyDelegation/kt27070.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested")