IC Mangling: Use correct java field type if the type is inline class
in old JVM BE. #KT-26445
This commit is contained in:
@@ -54,6 +54,7 @@ import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor;
|
|||||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||||
import org.jetbrains.kotlin.load.java.DescriptorsJvmAbiUtil;
|
import org.jetbrains.kotlin.load.java.DescriptorsJvmAbiUtil;
|
||||||
|
import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor;
|
||||||
import org.jetbrains.kotlin.load.kotlin.DescriptorBasedTypeSignatureMappingKt;
|
import org.jetbrains.kotlin.load.kotlin.DescriptorBasedTypeSignatureMappingKt;
|
||||||
import org.jetbrains.kotlin.load.kotlin.MethodSignatureMappingKt;
|
import org.jetbrains.kotlin.load.kotlin.MethodSignatureMappingKt;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
@@ -2404,9 +2405,14 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
fieldName = KotlinTypeMapper.mapDefaultFieldName(propertyDescriptor, isDelegatedProperty);
|
fieldName = KotlinTypeMapper.mapDefaultFieldName(propertyDescriptor, isDelegatedProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KotlinType propertyType = propertyDescriptor.getOriginal().getType();
|
||||||
|
if (propertyDescriptor instanceof JavaPropertyDescriptor && InlineClassesUtilsKt.isInlineClassType(propertyType)) {
|
||||||
|
propertyType = TypeUtils.makeNullable(propertyType);
|
||||||
|
}
|
||||||
|
|
||||||
return StackValue.property(
|
return StackValue.property(
|
||||||
propertyDescriptor, backingFieldOwner,
|
propertyDescriptor, backingFieldOwner,
|
||||||
typeMapper.mapType(isDelegatedProperty && forceField ? delegateType : propertyDescriptor.getOriginal().getType()),
|
typeMapper.mapType(isDelegatedProperty && forceField ? delegateType : propertyType),
|
||||||
isStaticBackingField, fieldName, callableGetter, callableSetter, receiver, this, resolvedCall, skipLateinitAssertion,
|
isStaticBackingField, fieldName, callableGetter, callableSetter, receiver, this, resolvedCall, skipLateinitAssertion,
|
||||||
isDelegatedProperty && forceField ? delegateType : null
|
isDelegatedProperty && forceField ? delegateType : null
|
||||||
);
|
);
|
||||||
@@ -4375,6 +4381,10 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
|
|
||||||
Type exprType = expressionType(expr);
|
Type exprType = expressionType(expr);
|
||||||
KotlinType exprKotlinType = kotlinType(expr);
|
KotlinType exprKotlinType = kotlinType(expr);
|
||||||
|
if (exprKotlinType != null && InlineClassesUtilsKt.isInlineClassType(exprKotlinType) &&
|
||||||
|
FlexibleTypesKt.isNullabilityFlexible(exprKotlinType)) {
|
||||||
|
exprKotlinType = TypeUtils.makeNullable(exprKotlinType);
|
||||||
|
}
|
||||||
StackValue value;
|
StackValue value;
|
||||||
if (compileTimeConstant != null) {
|
if (compileTimeConstant != null) {
|
||||||
value = StackValue.constant(compileTimeConstant.getValue(), exprType, exprKotlinType);
|
value = StackValue.constant(compileTimeConstant.getValue(), exprType, exprKotlinType);
|
||||||
|
|||||||
Generated
+10
@@ -15129,6 +15129,16 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
public void testInlineClasInSignature() throws Exception {
|
public void testInlineClasInSignature() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignature.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignature.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineClasInSignatureNonNull.kt")
|
||||||
|
public void testInlineClasInSignatureNonNull() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignatureNonNull.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineClasInSignatureNullable.kt")
|
||||||
|
public void testInlineClasInSignatureNullable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignatureNullable.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods")
|
@TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods")
|
||||||
|
|||||||
+8
-6
@@ -5,16 +5,14 @@
|
|||||||
// FILE: WithInlineClass.java
|
// FILE: WithInlineClass.java
|
||||||
|
|
||||||
import kotlin.UInt;
|
import kotlin.UInt;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class WithInlineClass {
|
public class WithInlineClass {
|
||||||
private static UInt UINT = null;
|
public static UInt UINT = null;
|
||||||
|
|
||||||
public static void acceptsUInt(@NotNull UInt u) {
|
public static void acceptsUInt(UInt u) {
|
||||||
UINT = u;
|
UINT = u;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static UInt provideUInt() {
|
public static UInt provideUInt() {
|
||||||
return UINT;
|
return UINT;
|
||||||
}
|
}
|
||||||
@@ -24,6 +22,10 @@ public class WithInlineClass {
|
|||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
WithInlineClass.acceptsUInt(1u)
|
WithInlineClass.acceptsUInt(1u)
|
||||||
val res = WithInlineClass.provideUInt()
|
var res = WithInlineClass.provideUInt()
|
||||||
return if (res == 1u) "OK" else "FAIL $res"
|
if (res != 1u) return "FAIL 1 $res"
|
||||||
|
WithInlineClass.UINT = 2u
|
||||||
|
res = WithInlineClass.UINT
|
||||||
|
if (res != 2u) return "FAIL 2 $res"
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
// LANGUAGE: +InlineClasses
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
// FILE: WithInlineClass.java
|
||||||
|
|
||||||
|
import kotlin.UInt;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class WithInlineClass {
|
||||||
|
@NotNull
|
||||||
|
public static UInt UINT = null;
|
||||||
|
|
||||||
|
public static void acceptsUInt(@NotNull UInt u) {
|
||||||
|
UINT = u;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static UInt provideUInt() {
|
||||||
|
return UINT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: box.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
WithInlineClass.acceptsUInt(1u)
|
||||||
|
var res = WithInlineClass.provideUInt()
|
||||||
|
if (res != 1u) return "FAIL 1 $res"
|
||||||
|
WithInlineClass.UINT = 2u
|
||||||
|
res = WithInlineClass.UINT
|
||||||
|
if (res != 2u) return "FAIL 2 $res"
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
// LANGUAGE: +InlineClasses
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
// FILE: WithInlineClass.java
|
||||||
|
|
||||||
|
import kotlin.UInt;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class WithInlineClass {
|
||||||
|
@Nullable
|
||||||
|
public static UInt UINT = null;
|
||||||
|
|
||||||
|
public static void acceptsUInt(@Nullable UInt u) {
|
||||||
|
UINT = u;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static UInt provideUInt() {
|
||||||
|
return UINT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: box.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
WithInlineClass.acceptsUInt(1u)
|
||||||
|
var res = WithInlineClass.provideUInt()
|
||||||
|
if (res != 1u) return "FAIL 1 $res"
|
||||||
|
WithInlineClass.UINT = 2u
|
||||||
|
res = WithInlineClass.UINT
|
||||||
|
if (res != 2u) return "FAIL 2 $res"
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+10
@@ -15129,6 +15129,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
public void testInlineClasInSignature() throws Exception {
|
public void testInlineClasInSignature() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignature.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignature.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineClasInSignatureNonNull.kt")
|
||||||
|
public void testInlineClasInSignatureNonNull() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignatureNonNull.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineClasInSignatureNullable.kt")
|
||||||
|
public void testInlineClasInSignatureNullable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignatureNullable.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods")
|
@TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods")
|
||||||
|
|||||||
+10
@@ -15129,6 +15129,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
public void testInlineClasInSignature() throws Exception {
|
public void testInlineClasInSignature() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignature.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignature.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineClasInSignatureNonNull.kt")
|
||||||
|
public void testInlineClasInSignatureNonNull() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignatureNonNull.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineClasInSignatureNullable.kt")
|
||||||
|
public void testInlineClasInSignatureNullable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignatureNullable.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods")
|
@TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods")
|
||||||
|
|||||||
+10
@@ -15129,6 +15129,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
public void testInlineClasInSignature() throws Exception {
|
public void testInlineClasInSignature() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignature.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignature.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineClasInSignatureNonNull.kt")
|
||||||
|
public void testInlineClasInSignatureNonNull() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignatureNonNull.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineClasInSignatureNullable.kt")
|
||||||
|
public void testInlineClasInSignatureNullable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/javaInterop/inlineClasInSignatureNullable.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods")
|
@TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods")
|
||||||
|
|||||||
Reference in New Issue
Block a user