KT-28585 Fix boxing for values of captured vars of inline class type
This commit is contained in:
@@ -728,15 +728,20 @@ public abstract class StackValue {
|
|||||||
@NotNull Field refWrapper,
|
@NotNull Field refWrapper,
|
||||||
@NotNull VariableDescriptor variableDescriptor
|
@NotNull VariableDescriptor variableDescriptor
|
||||||
) {
|
) {
|
||||||
return new FieldForSharedVar(localType, classType, fieldName, refWrapper,
|
return new FieldForSharedVar(
|
||||||
variableDescriptor.isLateInit(), variableDescriptor.getName());
|
localType, variableDescriptor.getType(), classType, fieldName, refWrapper,
|
||||||
|
variableDescriptor.isLateInit(), variableDescriptor.getName()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static FieldForSharedVar fieldForSharedVar(@NotNull FieldForSharedVar field, @NotNull StackValue newReceiver) {
|
public static FieldForSharedVar fieldForSharedVar(@NotNull FieldForSharedVar field, @NotNull StackValue newReceiver) {
|
||||||
Field oldReceiver = (Field) field.receiver;
|
Field oldReceiver = (Field) field.receiver;
|
||||||
Field newSharedVarReceiver = field(oldReceiver, newReceiver);
|
Field newSharedVarReceiver = field(oldReceiver, newReceiver);
|
||||||
return new FieldForSharedVar(field.type, field.owner, field.name, newSharedVarReceiver, field.isLateinit, field.variableName);
|
return new FieldForSharedVar(
|
||||||
|
field.type, field.kotlinType,
|
||||||
|
field.owner, field.name, newSharedVarReceiver, field.isLateinit, field.variableName
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StackValue coercion(@NotNull StackValue value, @NotNull Type castType, @Nullable KotlinType castKotlinType) {
|
public static StackValue coercion(@NotNull StackValue value, @NotNull Type castType, @Nullable KotlinType castKotlinType) {
|
||||||
@@ -1900,10 +1905,11 @@ public abstract class StackValue {
|
|||||||
final Name variableName;
|
final Name variableName;
|
||||||
|
|
||||||
public FieldForSharedVar(
|
public FieldForSharedVar(
|
||||||
Type type, Type owner, String name, StackValue.Field receiver,
|
Type type, KotlinType kotlinType,
|
||||||
|
Type owner, String name, StackValue.Field receiver,
|
||||||
boolean isLateinit, Name variableName
|
boolean isLateinit, Name variableName
|
||||||
) {
|
) {
|
||||||
super(type, null, false, false, receiver, receiver.canHaveSideEffects());
|
super(type, kotlinType, false, false, receiver, receiver.canHaveSideEffects());
|
||||||
|
|
||||||
if (isLateinit && variableName == null) {
|
if (isLateinit && variableName == null) {
|
||||||
throw new IllegalArgumentException("variableName should be non-null for captured lateinit variable " + name);
|
throw new IllegalArgumentException("variableName should be non-null for captured lateinit variable " + name);
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// !LANGUAGE: +InlineClasses
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// IGNORE_BACKEND: JVM_IR
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var uint1 = 1u
|
||||||
|
var uint2 = 2u
|
||||||
|
var uint3 = 3u
|
||||||
|
val uintSet = mutableSetOf(uint1)
|
||||||
|
uintSet.add(uint2);
|
||||||
|
{
|
||||||
|
uintSet.add(uint3)
|
||||||
|
if (!uintSet.contains(1u)) throw AssertionError()
|
||||||
|
if (!uintSet.contains(2u)) throw AssertionError()
|
||||||
|
if (!uintSet.contains(3u)) throw AssertionError()
|
||||||
|
}()
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+5
@@ -12125,6 +12125,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28405.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/kt28405.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt28585.kt")
|
||||||
|
public void testKt28585() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("mapInlineClassesWithSuppressWildcardsMode.kt")
|
@TestMetadata("mapInlineClassesWithSuppressWildcardsMode.kt")
|
||||||
public void testMapInlineClassesWithSuppressWildcardsMode() throws Exception {
|
public void testMapInlineClassesWithSuppressWildcardsMode() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/mapInlineClassesWithSuppressWildcardsMode.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/mapInlineClassesWithSuppressWildcardsMode.kt");
|
||||||
|
|||||||
+5
@@ -12125,6 +12125,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28405.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/kt28405.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt28585.kt")
|
||||||
|
public void testKt28585() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("mapInlineClassesWithSuppressWildcardsMode.kt")
|
@TestMetadata("mapInlineClassesWithSuppressWildcardsMode.kt")
|
||||||
public void testMapInlineClassesWithSuppressWildcardsMode() throws Exception {
|
public void testMapInlineClassesWithSuppressWildcardsMode() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/mapInlineClassesWithSuppressWildcardsMode.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/mapInlineClassesWithSuppressWildcardsMode.kt");
|
||||||
|
|||||||
+5
@@ -12130,6 +12130,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28405.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/kt28405.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt28585.kt")
|
||||||
|
public void testKt28585() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("mapInlineClassesWithSuppressWildcardsMode.kt")
|
@TestMetadata("mapInlineClassesWithSuppressWildcardsMode.kt")
|
||||||
public void testMapInlineClassesWithSuppressWildcardsMode() throws Exception {
|
public void testMapInlineClassesWithSuppressWildcardsMode() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/mapInlineClassesWithSuppressWildcardsMode.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/mapInlineClassesWithSuppressWildcardsMode.kt");
|
||||||
|
|||||||
+5
@@ -10495,6 +10495,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28405.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/kt28405.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt28585.kt")
|
||||||
|
public void testKt28585() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt")
|
@TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt")
|
||||||
public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception {
|
public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt");
|
||||||
|
|||||||
+5
@@ -11550,6 +11550,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28405.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/kt28405.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt28585.kt")
|
||||||
|
public void testKt28585() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt")
|
@TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt")
|
||||||
public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception {
|
public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user