Support property delegation to inline class values (KT-27070)

This commit is contained in:
Dmitry Petrov
2018-10-01 12:58:39 +03:00
parent 70e60ea9bc
commit 5480bf69e8
18 changed files with 582 additions and 16 deletions
@@ -2153,7 +2153,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> 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<StackValue, StackValue> 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
@@ -510,19 +510,29 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
propertyDescriptor, true, false, null, true, StackValue.LOCAL_0, null, false
);
ResolvedCall<FunctionDescriptor> 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<FunctionDescriptor> 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.
@@ -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);
@@ -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 <code>kotlinType</code> with the <code>delegateKotlinType</code>
* (so that type coercion will work properly),
* and <code>delegateKotlinType</code> with <code>null</code>
* (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
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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<Foo, Int> {
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"
}
@@ -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
@@ -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")
@@ -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");
@@ -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")
@@ -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")
@@ -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")
@@ -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")