Native: improve ClassCastException message for local classes
Previously it was like "null cannot be cast to MyObject" or "MyObject cannot be cast to null", because `KClass.qualifiedName` is `null` for local classes (including anonymous ones). Use `KClass.toString()` instead, for both object actual dynamic type and cast target type. This string representation is generally more meaningful for such cases, and contains useful details for local classes.
This commit is contained in:
committed by
Space
parent
5c612078e5
commit
cf581738c3
+10
@@ -3614,6 +3614,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/casts/mutableCollections/weirdMutableCasts.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/casts/nativeCCEMessage")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class NativeCCEMessage {
|
||||
@Test
|
||||
public void testAllFilesPresentInNativeCCEMessage() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/casts/nativeCCEMessage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+10
@@ -3656,6 +3656,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/casts/mutableCollections/weirdMutableCasts.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/casts/nativeCCEMessage")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class NativeCCEMessage {
|
||||
@Test
|
||||
public void testAllFilesPresentInNativeCCEMessage() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/casts/nativeCCEMessage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+13
@@ -3237,6 +3237,19 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/casts/mutableCollections/weirdMutableCasts.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/casts/nativeCCEMessage")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class NativeCCEMessage extends AbstractIrCodegenBoxWasmTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNativeCCEMessage() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/casts/nativeCCEMessage"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/checkcastOptimization")
|
||||
|
||||
Reference in New Issue
Block a user