Use precalculated intersection type in JVM backend
also test all backends for the problem in the issue #KT-37715 fixed
This commit is contained in:
Generated
+5
@@ -28798,6 +28798,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/vararg/kt1978.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37715.kt")
|
||||
public void testKt37715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt37715.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37779.kt")
|
||||
public void testKt37779() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt37779.kt");
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// WITH_RUNTIME
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
import kotlin.collections.toList
|
||||
|
||||
fun <T: Number> foo(vararg values: T) = values.toList()
|
||||
|
||||
fun box(): String {
|
||||
val a = foo(1, 4.5)
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -30384,6 +30384,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt1978.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37715.kt")
|
||||
public void testKt37715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt37715.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37779.kt")
|
||||
public void testKt37779() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt37779.kt");
|
||||
|
||||
+5
@@ -29201,6 +29201,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/vararg/kt1978.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37715.kt")
|
||||
public void testKt37715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt37715.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37779.kt")
|
||||
public void testKt37779() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt37779.kt");
|
||||
|
||||
+5
@@ -28798,6 +28798,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/vararg/kt1978.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37715.kt")
|
||||
public void testKt37715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt37715.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37779.kt")
|
||||
public void testKt37779() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt37779.kt");
|
||||
|
||||
@@ -77,7 +77,8 @@ fun <T : Any> mapType(
|
||||
|
||||
val constructor = kotlinType.constructor
|
||||
if (constructor is IntersectionTypeConstructor) {
|
||||
val commonSupertype = typeMappingConfiguration.commonSupertype(constructor.supertypes)
|
||||
val intersectionType = constructor.getAlternativeType() ?:
|
||||
typeMappingConfiguration.commonSupertype(constructor.supertypes)
|
||||
// interface In<in E>
|
||||
// open class A : In<A>
|
||||
// open class B : In<B>
|
||||
@@ -85,7 +86,7 @@ fun <T : Any> mapType(
|
||||
// So replace arguments with star-projections to prevent infinite recursive mapping
|
||||
// It's not very important because such types anyway are prohibited in declarations
|
||||
return mapType(
|
||||
commonSupertype.replaceArgumentsWithStarProjections(),
|
||||
intersectionType.replaceArgumentsWithStarProjections(),
|
||||
factory, mode, typeMappingConfiguration, descriptorTypeWriter, writeGenericType
|
||||
)
|
||||
}
|
||||
|
||||
Generated
+5
@@ -23299,6 +23299,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt1978.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37715.kt")
|
||||
public void testKt37715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt37715.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37779.kt")
|
||||
public void testKt37779() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt37779.kt");
|
||||
|
||||
+5
@@ -23359,6 +23359,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt1978.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37715.kt")
|
||||
public void testKt37715() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt37715.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37779.kt")
|
||||
public void testKt37779() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt37779.kt");
|
||||
|
||||
Reference in New Issue
Block a user