JVM_IR KT-48987 handle star projection arguments in smart casts
This commit is contained in:
committed by
Alexander Udalov
parent
944fa7e2f8
commit
c74453d8d2
+6
@@ -4589,6 +4589,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/casts/kt48927_privateMethodOnDerivedCastToBase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48987.kt")
|
||||
public void testKt48987() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/casts/kt48987.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaToUnitCast.kt")
|
||||
public void testLambdaToUnitCast() throws Exception {
|
||||
|
||||
+6
-1
@@ -532,7 +532,12 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext)
|
||||
else irFunctionReference.getArgumentsWithIr().singleOrNull()
|
||||
|
||||
// The type of the reference is KFunction<in A1, ..., in An, out R>
|
||||
private val parameterTypes = (irFunctionReference.type as IrSimpleType).arguments.map { (it as IrTypeProjection).type }
|
||||
private val parameterTypes = (irFunctionReference.type as IrSimpleType).arguments.map {
|
||||
when (it) {
|
||||
is IrTypeProjection -> it.type
|
||||
else -> context.irBuiltIns.anyNType
|
||||
}
|
||||
}
|
||||
private val argumentTypes = parameterTypes.dropLast(1)
|
||||
private val referenceReturnType = parameterTypes.last()
|
||||
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WITH_STDLIB
|
||||
|
||||
fun box(): String {
|
||||
return try {
|
||||
val range1 = 0..1
|
||||
range1 as List<Double>
|
||||
range1.joinToString { "" }
|
||||
} catch (e: java.lang.ClassCastException) {
|
||||
"OK"
|
||||
}
|
||||
}
|
||||
+6
@@ -4589,6 +4589,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/casts/kt48927_privateMethodOnDerivedCastToBase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48987.kt")
|
||||
public void testKt48987() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/casts/kt48987.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaToUnitCast.kt")
|
||||
public void testLambdaToUnitCast() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user