Support mapping for inline classes based on type variables
This commit is contained in:
@@ -477,7 +477,7 @@ public class KotlinTypeMapper {
|
||||
|
||||
@NotNull
|
||||
public static Type mapUnderlyingTypeOfInlineClassType(@NotNull KotlinType kotlinType) {
|
||||
KotlinType underlyingType = InlineClassesUtilsKt.underlyingTypeOfInlineClassType(kotlinType);
|
||||
KotlinType underlyingType = InlineClassesUtilsKt.unsubstitutedUnderlyingType(kotlinType);
|
||||
if (underlyingType == null) {
|
||||
throw new IllegalStateException("There should be underlying type for inline class type: " + kotlinType);
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class Foo<T>(val x: List<T>)
|
||||
|
||||
object Test {
|
||||
fun nonNullTypeArgument(f: Foo<Int>) {}
|
||||
fun nullableTypeArgument(f: Foo<String?>) {}
|
||||
|
||||
fun nullableValue(f: Foo<Long>?) {}
|
||||
}
|
||||
|
||||
// method: Test::nonNullTypeArgument
|
||||
// jvm signature: (Ljava/util/List;)V
|
||||
// generic signature: (Ljava/util/List<Ljava/lang/Integer;>;)V
|
||||
|
||||
// method: Test::nullableTypeArgument
|
||||
// jvm signature: (Ljava/util/List;)V
|
||||
// generic signature: (Ljava/util/List<Ljava/lang/String;>;)V
|
||||
|
||||
// method: Test::nullableValue
|
||||
// jvm signature: (Ljava/util/List;)V
|
||||
// generic signature: (Ljava/util/List<Ljava/lang/Long;>;)V
|
||||
|
||||
// method: Foo$Erased::box
|
||||
// jvm signature: (Ljava/util/List;)LFoo;
|
||||
// generic signature: null
|
||||
|
||||
// method: Foo::unbox
|
||||
// jvm signature: ()Ljava/util/List;
|
||||
// generic signature: ()Ljava/util/List<TT;>;
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class Default<T>(val x: T)
|
||||
|
||||
class Inv<T>
|
||||
|
||||
object Test {
|
||||
fun withNotNullPrimitive(a: Default<Int>) {}
|
||||
fun withAdditionalGenericParameter(x: Inv<String>, y: Default<String>) {}
|
||||
|
||||
fun asNullable(a: Default<Int>?) {}
|
||||
|
||||
fun asNullableTypeArgument(a: Default<Int?>) {}
|
||||
fun asNullableAndNullableTypeArgument(a: Default<Int?>?) {}
|
||||
}
|
||||
|
||||
// method: Test::withNotNullPrimitive
|
||||
// jvm signature: (Ljava/lang/Object;)V
|
||||
// generic signature: null
|
||||
|
||||
// method: Test::withAdditionalGenericParameter
|
||||
// jvm signature: (LInv;Ljava/lang/Object;)V
|
||||
// generic signature: (LInv<Ljava/lang/String;>;Ljava/lang/Object;)V
|
||||
|
||||
// method: Test::asNullable
|
||||
// jvm signature: (LDefault;)V
|
||||
// generic signature: (LDefault<Ljava/lang/Integer;>;)V
|
||||
|
||||
// method: Test::asNullableTypeArgument
|
||||
// jvm signature: (Ljava/lang/Object;)V
|
||||
// generic signature: null
|
||||
|
||||
// method: Test::asNullableAndNullableTypeArgument
|
||||
// jvm signature: (LDefault;)V
|
||||
// generic signature: (LDefault<Ljava/lang/Integer;>;)V
|
||||
|
||||
// method: Default$Erased:box
|
||||
// jvm signature: (Ljava/lang/Object;)LDefault;
|
||||
// generic signature: null
|
||||
|
||||
// method: Default:unbox
|
||||
// jvm signature: ()Ljava/lang/Object
|
||||
// generic signature: null
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class NonNull<T : Any>(val x: T)
|
||||
inline class NullableValue<T : Any>(val x: T?)
|
||||
|
||||
object Test {
|
||||
fun withNotNullPrimitive(a: NonNull<Int>) {}
|
||||
fun asNullable(a: NonNull<Int>?) {}
|
||||
|
||||
fun withNotNullForNullableValue(a: NullableValue<Int>) {}
|
||||
fun asNullableForNullableValue(a: NullableValue<Int>?) {}
|
||||
}
|
||||
|
||||
// method: Test::withNotNullPrimitive
|
||||
// jvm signature: (Ljava/lang/Object;)V
|
||||
// generic signature: null
|
||||
|
||||
// method: Test::asNullable
|
||||
// jvm signature: (Ljava/lang/Object;)V
|
||||
// generic signature: null
|
||||
|
||||
// method: Test::withNotNullForNullableValue
|
||||
// jvm signature: (Ljava/lang/Object;)V
|
||||
// generic signature: null
|
||||
|
||||
// method: Test::asNullableForNullableValue
|
||||
// jvm signature: (LNullableValue;)V
|
||||
// generic signature: (LNullableValue<Ljava/lang/Integer;>;)V
|
||||
@@ -1944,6 +1944,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassCallsDefaultValue.kt")
|
||||
public void testInlineClassCallsDefaultValue() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/inlineClasses/inlineClassCallsDefaultValue.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("unboxInlineClassAfterSafeCall.kt")
|
||||
public void testUnboxInlineClassAfterSafeCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/inlineClasses/unboxInlineClassAfterSafeCall.kt");
|
||||
|
||||
+18
@@ -564,6 +564,24 @@ public class WriteSignatureTestGenerated extends AbstractWriteSignatureTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("genericInlineClassBasedOnGenericType.kt")
|
||||
public void testGenericInlineClassBasedOnGenericType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeSignature/inlineClasses/genericInlineClassBasedOnGenericType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("genericInlineClassWithDefaultTypeParameter.kt")
|
||||
public void testGenericInlineClassWithDefaultTypeParameter() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeSignature/inlineClasses/genericInlineClassWithDefaultTypeParameter.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("genericInlineClassWithNotNullTypeParameter.kt")
|
||||
public void testGenericInlineClassWithNotNullTypeParameter() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeSignature/inlineClasses/genericInlineClassWithNotNullTypeParameter.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nullableInlineClassType.kt")
|
||||
public void testNullableInlineClassType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeSignature/inlineClasses/nullableInlineClassType.kt");
|
||||
|
||||
Reference in New Issue
Block a user