Improve toString of platform types created by typeOf

In the stdlib implementation, render "!" if the type is only
nullability-flexible. Otherwise, render "($lower..$upper)".

Note that full kotlin-reflect has a much more complicated logic (see
`DescriptorRendererImpl.renderFlexibleType`) that renders things like
`(Mutable)List` and so on. It is not a goal of the stdlib implementation
to replicate all of that, since it requires copying a large amount of
code, namely the entirety of `JavaToKotlinClassMap` to map Java class
names to Kotlin.
This commit is contained in:
Alexander Udalov
2021-07-08 22:34:43 +02:00
parent ddfa94e7e9
commit a7e48c3af1
10 changed files with 157 additions and 12 deletions
@@ -37479,6 +37479,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/reflection/typeOf/nothing_before.kt");
}
@Test
@TestMetadata("primitiveJavaTypes.kt")
public void testPrimitiveJavaTypes() throws Exception {
runTest("compiler/testData/codegen/box/reflection/typeOf/primitiveJavaTypes.kt");
}
@Test
@TestMetadata("rawTypes_after.kt")
public void testRawTypes_after() throws Exception {
@@ -37564,6 +37570,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/reflection/typeOf/noReflect/nothing_before.kt");
}
@Test
@TestMetadata("primitiveJavaTypes.kt")
public void testPrimitiveJavaTypes() throws Exception {
runTest("compiler/testData/codegen/box/reflection/typeOf/noReflect/primitiveJavaTypes.kt");
}
@Test
@TestMetadata("rawTypes_after.kt")
public void testRawTypes_after() throws Exception {
@@ -37521,6 +37521,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/reflection/typeOf/nothing_before.kt");
}
@Test
@TestMetadata("primitiveJavaTypes.kt")
public void testPrimitiveJavaTypes() throws Exception {
runTest("compiler/testData/codegen/box/reflection/typeOf/primitiveJavaTypes.kt");
}
@Test
@TestMetadata("rawTypes_after.kt")
public void testRawTypes_after() throws Exception {
@@ -37606,6 +37612,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/reflection/typeOf/noReflect/nothing_before.kt");
}
@Test
@TestMetadata("primitiveJavaTypes.kt")
public void testPrimitiveJavaTypes() throws Exception {
runTest("compiler/testData/codegen/box/reflection/typeOf/noReflect/primitiveJavaTypes.kt");
}
@Test
@TestMetadata("rawTypes_after.kt")
public void testRawTypes_after() throws Exception {