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 VariableDescriptor variableDescriptor
|
||||
) {
|
||||
return new FieldForSharedVar(localType, classType, fieldName, refWrapper,
|
||||
variableDescriptor.isLateInit(), variableDescriptor.getName());
|
||||
return new FieldForSharedVar(
|
||||
localType, variableDescriptor.getType(), classType, fieldName, refWrapper,
|
||||
variableDescriptor.isLateInit(), variableDescriptor.getName()
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FieldForSharedVar fieldForSharedVar(@NotNull FieldForSharedVar field, @NotNull StackValue newReceiver) {
|
||||
Field oldReceiver = (Field) field.receiver;
|
||||
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) {
|
||||
@@ -1900,10 +1905,11 @@ public abstract class StackValue {
|
||||
final Name variableName;
|
||||
|
||||
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
|
||||
) {
|
||||
super(type, null, false, false, receiver, receiver.canHaveSideEffects());
|
||||
super(type, kotlinType, false, false, receiver, receiver.canHaveSideEffects());
|
||||
|
||||
if (isLateinit && variableName == null) {
|
||||
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");
|
||||
}
|
||||
|
||||
@TestMetadata("kt28585.kt")
|
||||
public void testKt28585() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mapInlineClassesWithSuppressWildcardsMode.kt")
|
||||
public void testMapInlineClassesWithSuppressWildcardsMode() throws Exception {
|
||||
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");
|
||||
}
|
||||
|
||||
@TestMetadata("kt28585.kt")
|
||||
public void testKt28585() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mapInlineClassesWithSuppressWildcardsMode.kt")
|
||||
public void testMapInlineClassesWithSuppressWildcardsMode() throws Exception {
|
||||
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");
|
||||
}
|
||||
|
||||
@TestMetadata("kt28585.kt")
|
||||
public void testKt28585() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mapInlineClassesWithSuppressWildcardsMode.kt")
|
||||
public void testMapInlineClassesWithSuppressWildcardsMode() throws Exception {
|
||||
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");
|
||||
}
|
||||
|
||||
@TestMetadata("kt28585.kt")
|
||||
public void testKt28585() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt")
|
||||
public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception {
|
||||
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");
|
||||
}
|
||||
|
||||
@TestMetadata("kt28585.kt")
|
||||
public void testKt28585() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt")
|
||||
public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt");
|
||||
|
||||
Reference in New Issue
Block a user