JVM_IR: refactor ToArrayLowering and make matching more precise
* If `toArray` is inherited from Java, it may take an argument or
return a value of a flexible type, which looks nullable in IR;
* The returned array may also have `out` variance of the type
argument;
* `Array<T>` is not the same as `Array<Any?>` if `T` is neither `Any`
nor `in Something`, so presence of `toArray(): Array<T>` does not
mean we don't need to generate a new `toArray`.
This commit is contained in:
+5
@@ -28199,6 +28199,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/toArray/toArrayAlreadyPresent.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("toArrayFromJava.kt")
|
||||
public void testToArrayFromJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/toArray/toArrayFromJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("toArrayShouldBePublic.kt")
|
||||
public void testToArrayShouldBePublic() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/toArray/toArrayShouldBePublic.kt");
|
||||
|
||||
+5
@@ -26983,6 +26983,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ToArray extends AbstractLightAnalysisModeTest {
|
||||
@TestMetadata("toArrayFromJava.kt")
|
||||
public void ignoreToArrayFromJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/toArray/toArrayFromJava.kt");
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
+5
@@ -26683,6 +26683,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/toArray/toArrayAlreadyPresent.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("toArrayFromJava.kt")
|
||||
public void testToArrayFromJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/toArray/toArrayFromJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("toArrayShouldBePublic.kt")
|
||||
public void testToArrayShouldBePublic() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/toArray/toArrayShouldBePublic.kt");
|
||||
|
||||
Reference in New Issue
Block a user