Use proper KotlinType in get/set methods for property reference
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
+12
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.reflect.KMutableProperty0
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
operator fun <R> KMutableProperty0<R>.setValue(host: Any?, property: KProperty<*>, value: R) = set(value)
|
||||
operator fun <R> KMutableProperty0<R>.getValue(host: Any?, property: KProperty<*>): R = get()
|
||||
|
||||
inline class Foo(val i: Int)
|
||||
|
||||
var f = Foo(4)
|
||||
|
||||
fun modify(ref: KMutableProperty0<Foo>) {
|
||||
var a by ref
|
||||
a = Foo(1)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
modify(::f)
|
||||
if (f.i != 1) throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -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<UInt>
|
||||
) {
|
||||
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"
|
||||
}
|
||||
+20
@@ -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");
|
||||
|
||||
+20
@@ -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");
|
||||
|
||||
+20
@@ -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");
|
||||
|
||||
+20
@@ -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");
|
||||
|
||||
+20
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user