diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt index 34020514702..0bb179bb223 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt @@ -321,11 +321,12 @@ class PropertyReferenceCodegen( } codegen.markStartLineNumber(expression) + val type = target.type if (isGetter) { - value.put(OBJECT_TYPE, v) + value.put(OBJECT_TYPE, type, v) } else { val functionDescriptor = codegen.context.functionDescriptor - value.store(StackValue.local(codegen.frameMap.getIndex(functionDescriptor.valueParameters.last()), OBJECT_TYPE), v) + value.store(StackValue.local(codegen.frameMap.getIndex(functionDescriptor.valueParameters.last()), OBJECT_TYPE, type), v) } v.areturn(signature.returnType) } diff --git a/compiler/testData/codegen/box/inlineClasses/inlineClassFunctionInvoke.kt b/compiler/testData/codegen/box/inlineClasses/inlineClassFunctionInvoke.kt new file mode 100644 index 00000000000..1e5c276f710 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/inlineClassFunctionInvoke.kt @@ -0,0 +1,30 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME + +inline class Z(val int: Int) + +inline class Str(val string: String) + +inline class NStr(val string: String?) + +fun fooZ(x: Z) = x + +fun fooStr(x: Str) = x + +fun fooNStr(x: NStr) = x + + +fun box(): String { + val fnZ = ::fooZ + if (fnZ.invoke(Z(42)).int != 42) throw AssertionError() + + val fnStr = ::fooStr + if (fnStr.invoke(Str("str")).string != "str") throw AssertionError() + + val fnNStr = ::fooNStr + if (fnNStr.invoke(NStr(null)).string != null) throw AssertionError() + if (fnNStr.invoke(NStr("nstr")).string != "nstr") throw AssertionError() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/inlineClassPropertyReferenceGetAndSet.kt b/compiler/testData/codegen/box/inlineClasses/inlineClassPropertyReferenceGetAndSet.kt new file mode 100644 index 00000000000..ae7fc90bd29 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/inlineClassPropertyReferenceGetAndSet.kt @@ -0,0 +1,12 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME + +inline class Foo(val z: String) + +var f = Foo("zzz") + +fun box(): String { + (::f).set(Foo("OK")) + return (::f).get().z +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/kt25750.kt b/compiler/testData/codegen/box/inlineClasses/kt25750.kt new file mode 100644 index 00000000000..01bb5c4e37f --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/kt25750.kt @@ -0,0 +1,25 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME + +import kotlin.reflect.KMutableProperty0 +import kotlin.reflect.KProperty + +operator fun KMutableProperty0.setValue(host: Any?, property: KProperty<*>, value: R) = set(value) +operator fun KMutableProperty0.getValue(host: Any?, property: KProperty<*>): R = get() + +inline class Foo(val i: Int) + +var f = Foo(4) + +fun modify(ref: KMutableProperty0) { + var a by ref + a = Foo(1) +} + +fun box(): String { + modify(::f) + if (f.i != 1) throw AssertionError() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/unsignedTypes/kt25784.kt b/compiler/testData/codegen/box/unsignedTypes/kt25784.kt new file mode 100644 index 00000000000..b22c18a1143 --- /dev/null +++ b/compiler/testData/codegen/box/unsignedTypes/kt25784.kt @@ -0,0 +1,31 @@ +// WITH_UNSIGNED +// IGNORE_BACKEND: JVM_IR, JS_IR, JS + +import kotlin.reflect.KProperty +import kotlin.reflect.KProperty0 + +class ByteDelegate( + private val position: Int, + private val uIntValue: KProperty0 +) { + operator fun getValue(any: Any?, property: KProperty<*>): UByte { + val uInt = uIntValue.get() shr (position * 8) and 0xffu + return uInt.toUByte() + } +} + +class ByteDelegateTest { + val uInt = 0xA1B2C3u + val uByte by ByteDelegate(0, this::uInt) + + fun test() { + val actual = uByte + if (0xC3u.toUByte() != actual) throw AssertionError() + } +} + +fun box(): String { + ByteDelegateTest().test() + + return "OK" +} \ 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 1371266d735..6d348d5f8f3 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -11530,11 +11530,21 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassEqualityShouldUseTotalOrderForFloatingPointData.kt"); } + @TestMetadata("inlineClassFunctionInvoke.kt") + public void testInlineClassFunctionInvoke() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassFunctionInvoke.kt"); + } + @TestMetadata("inlineClassImplementsCollection.kt") public void testInlineClassImplementsCollection() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassImplementsCollection.kt"); } + @TestMetadata("inlineClassPropertyReferenceGetAndSet.kt") + public void testInlineClassPropertyReferenceGetAndSet() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassPropertyReferenceGetAndSet.kt"); + } + @TestMetadata("inlineClassValuesInsideStrings.kt") public void testInlineClassValuesInsideStrings() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassValuesInsideStrings.kt"); @@ -11570,6 +11580,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/kt25246.kt"); } + @TestMetadata("kt25750.kt") + public void testKt25750() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt25750.kt"); + } + @TestMetadata("kt25771.kt") public void testKt25771() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/kt25771.kt"); @@ -21985,6 +22000,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/unsignedTypes/iterateOverListOfBoxedUnsignedValues.kt"); } + @TestMetadata("kt25784.kt") + public void testKt25784() throws Exception { + runTest("compiler/testData/codegen/box/unsignedTypes/kt25784.kt"); + } + @TestMetadata("signedToUnsignedLiteralConversion.kt") public void testSignedToUnsignedLiteralConversion() throws Exception { runTest("compiler/testData/codegen/box/unsignedTypes/signedToUnsignedLiteralConversion.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 91408c1a58d..2c63fc54097 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -11530,11 +11530,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/inlineClassEqualityShouldUseTotalOrderForFloatingPointData.kt"); } + @TestMetadata("inlineClassFunctionInvoke.kt") + public void testInlineClassFunctionInvoke() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassFunctionInvoke.kt"); + } + @TestMetadata("inlineClassImplementsCollection.kt") public void testInlineClassImplementsCollection() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassImplementsCollection.kt"); } + @TestMetadata("inlineClassPropertyReferenceGetAndSet.kt") + public void testInlineClassPropertyReferenceGetAndSet() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassPropertyReferenceGetAndSet.kt"); + } + @TestMetadata("inlineClassValuesInsideStrings.kt") public void testInlineClassValuesInsideStrings() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassValuesInsideStrings.kt"); @@ -11570,6 +11580,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/kt25246.kt"); } + @TestMetadata("kt25750.kt") + public void testKt25750() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt25750.kt"); + } + @TestMetadata("kt25771.kt") public void testKt25771() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/kt25771.kt"); @@ -21985,6 +22000,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/unsignedTypes/iterateOverListOfBoxedUnsignedValues.kt"); } + @TestMetadata("kt25784.kt") + public void testKt25784() throws Exception { + runTest("compiler/testData/codegen/box/unsignedTypes/kt25784.kt"); + } + @TestMetadata("signedToUnsignedLiteralConversion.kt") public void testSignedToUnsignedLiteralConversion() throws Exception { runTest("compiler/testData/codegen/box/unsignedTypes/signedToUnsignedLiteralConversion.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index ecdd43a6bf6..f60cd50720c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -11530,11 +11530,21 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/inlineClassEqualityShouldUseTotalOrderForFloatingPointData.kt"); } + @TestMetadata("inlineClassFunctionInvoke.kt") + public void testInlineClassFunctionInvoke() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassFunctionInvoke.kt"); + } + @TestMetadata("inlineClassImplementsCollection.kt") public void testInlineClassImplementsCollection() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassImplementsCollection.kt"); } + @TestMetadata("inlineClassPropertyReferenceGetAndSet.kt") + public void testInlineClassPropertyReferenceGetAndSet() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassPropertyReferenceGetAndSet.kt"); + } + @TestMetadata("inlineClassValuesInsideStrings.kt") public void testInlineClassValuesInsideStrings() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassValuesInsideStrings.kt"); @@ -11570,6 +11580,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/kt25246.kt"); } + @TestMetadata("kt25750.kt") + public void testKt25750() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt25750.kt"); + } + @TestMetadata("kt25771.kt") public void testKt25771() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/kt25771.kt"); @@ -21985,6 +22000,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/unsignedTypes/iterateOverListOfBoxedUnsignedValues.kt"); } + @TestMetadata("kt25784.kt") + public void testKt25784() throws Exception { + runTest("compiler/testData/codegen/box/unsignedTypes/kt25784.kt"); + } + @TestMetadata("signedToUnsignedLiteralConversion.kt") public void testSignedToUnsignedLiteralConversion() throws Exception { runTest("compiler/testData/codegen/box/unsignedTypes/signedToUnsignedLiteralConversion.kt"); 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 f80fd9b58ec..cec47a54f2e 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 @@ -10100,6 +10100,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassEqualityShouldUseTotalOrderForFloatingPointData.kt"); } + @TestMetadata("inlineClassFunctionInvoke.kt") + public void testInlineClassFunctionInvoke() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassFunctionInvoke.kt"); + } + + @TestMetadata("inlineClassPropertyReferenceGetAndSet.kt") + public void testInlineClassPropertyReferenceGetAndSet() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassPropertyReferenceGetAndSet.kt"); + } + @TestMetadata("inlineClassValuesInsideStrings.kt") public void testInlineClassValuesInsideStrings() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassValuesInsideStrings.kt"); @@ -10135,6 +10145,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/kt25246.kt"); } + @TestMetadata("kt25750.kt") + public void testKt25750() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt25750.kt"); + } + @TestMetadata("kt25771.kt") public void testKt25771() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/kt25771.kt"); @@ -19840,6 +19855,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/unsignedTypes/iterateOverListOfBoxedUnsignedValues.kt"); } + @TestMetadata("kt25784.kt") + public void testKt25784() throws Exception { + runTest("compiler/testData/codegen/box/unsignedTypes/kt25784.kt"); + } + @TestMetadata("signedToUnsignedLiteralConversion.kt") public void testSignedToUnsignedLiteralConversion() throws Exception { runTest("compiler/testData/codegen/box/unsignedTypes/signedToUnsignedLiteralConversion.kt"); 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 78983264edd..b2d63b21045 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 @@ -11160,6 +11160,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassEqualityShouldUseTotalOrderForFloatingPointData.kt"); } + @TestMetadata("inlineClassFunctionInvoke.kt") + public void testInlineClassFunctionInvoke() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassFunctionInvoke.kt"); + } + + @TestMetadata("inlineClassPropertyReferenceGetAndSet.kt") + public void testInlineClassPropertyReferenceGetAndSet() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassPropertyReferenceGetAndSet.kt"); + } + @TestMetadata("inlineClassValuesInsideStrings.kt") public void testInlineClassValuesInsideStrings() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassValuesInsideStrings.kt"); @@ -11195,6 +11205,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/kt25246.kt"); } + @TestMetadata("kt25750.kt") + public void testKt25750() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt25750.kt"); + } + @TestMetadata("kt25771.kt") public void testKt25771() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/kt25771.kt"); @@ -20900,6 +20915,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/unsignedTypes/iterateOverListOfBoxedUnsignedValues.kt"); } + @TestMetadata("kt25784.kt") + public void testKt25784() throws Exception { + runTest("compiler/testData/codegen/box/unsignedTypes/kt25784.kt"); + } + @TestMetadata("signedToUnsignedLiteralConversion.kt") public void testSignedToUnsignedLiteralConversion() throws Exception { runTest("compiler/testData/codegen/box/unsignedTypes/signedToUnsignedLiteralConversion.kt");