Refine type mapping for nullable inline class types
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
// !LANGUAGE: +InlineClasses
|
||||||
|
|
||||||
|
inline class InlinePrimitive(val x: Int)
|
||||||
|
inline class InlineReference(val y: String)
|
||||||
|
inline class InlineNullablePrimitive(val x: Int?)
|
||||||
|
inline class InlineNullableReference(val y: String?)
|
||||||
|
|
||||||
|
object Test {
|
||||||
|
fun withPrimitiveAsNullable(a: InlinePrimitive?) {}
|
||||||
|
fun withReferenceAsNullable(a: InlineReference?) {}
|
||||||
|
|
||||||
|
fun withNullablePrimitiveAsNullable(a: InlineNullablePrimitive?) {}
|
||||||
|
fun withNullableReferenceAsNullable(a: InlineNullableReference?) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// method: Test::withPrimitiveAsNullable
|
||||||
|
// jvm signature: (LInlinePrimitive;)V
|
||||||
|
// generic signature: null
|
||||||
|
|
||||||
|
// method: Test::withReferenceAsNullable
|
||||||
|
// jvm signature: (Ljava/lang/String;)V
|
||||||
|
// generic signature: null
|
||||||
|
|
||||||
|
// method: Test::withNullablePrimitiveAsNullable
|
||||||
|
// jvm signature: (LInlineNullablePrimitive;)V
|
||||||
|
// generic signature: null
|
||||||
|
|
||||||
|
// method: Test::withNullableReferenceAsNullable
|
||||||
|
// jvm signature: (LInlineNullableReference;)V
|
||||||
|
// generic signature: null
|
||||||
+6
@@ -558,6 +558,12 @@ public class WriteSignatureTestGenerated extends AbstractWriteSignatureTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeSignature/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeSignature/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nullableInlineClassType.kt")
|
||||||
|
public void testNullableInlineClassType() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeSignature/inlineClasses/nullableInlineClassType.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleSignatureWithInlineClassTypesAsPrimitive.kt")
|
@TestMetadata("simpleSignatureWithInlineClassTypesAsPrimitive.kt")
|
||||||
public void testSimpleSignatureWithInlineClassTypesAsPrimitive() throws Exception {
|
public void testSimpleSignatureWithInlineClassTypesAsPrimitive() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeSignature/inlineClasses/simpleSignatureWithInlineClassTypesAsPrimitive.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeSignature/inlineClasses/simpleSignatureWithInlineClassTypesAsPrimitive.kt");
|
||||||
|
|||||||
@@ -132,7 +132,13 @@ fun <T : Any> mapType(
|
|||||||
if (descriptor.isInline && !mode.needInlineClassWrapping) {
|
if (descriptor.isInline && !mode.needInlineClassWrapping) {
|
||||||
val underlyingType = descriptor.underlyingRepresentation()?.type
|
val underlyingType = descriptor.underlyingRepresentation()?.type
|
||||||
if (underlyingType != null) {
|
if (underlyingType != null) {
|
||||||
return mapType(underlyingType, factory, mode, typeMappingConfiguration, descriptorTypeWriter, writeGenericType)
|
if (!kotlinType.isMarkedNullable) {
|
||||||
|
return mapType(underlyingType, factory, mode, typeMappingConfiguration, descriptorTypeWriter, writeGenericType)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!underlyingType.isMarkedNullable && !KotlinBuiltIns.isPrimitiveType(underlyingType)) {
|
||||||
|
return mapType(underlyingType, factory, mode, typeMappingConfiguration, descriptorTypeWriter, writeGenericType)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user