FIR: Fix exception on remaining flexible ILT in lambda
^KT-49191 Related
This commit is contained in:
committed by
TeamCityServer
parent
bbc93d597a
commit
10c5d987d7
+6
@@ -16336,6 +16336,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/fir/Fir2IrClassifierStorage.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("flexibleIntegerLiterals.kt")
|
||||
public void testFlexibleIntegerLiterals() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitNothingInDelegate.kt")
|
||||
public void testImplicitNothingInDelegate() throws Exception {
|
||||
|
||||
@@ -145,11 +145,27 @@ class ConeIntegerLiteralTypeImpl : ConeIntegerLiteralType {
|
||||
}
|
||||
}
|
||||
|
||||
fun ConeKotlinType.approximateIntegerLiteralType(expectedType: ConeKotlinType? = null): ConeKotlinType =
|
||||
(this as? ConeIntegerLiteralType)?.getApproximatedType(expectedType) ?: this
|
||||
fun ConeKotlinType.approximateIntegerLiteralType(expectedType: ConeKotlinType? = null): ConeKotlinType {
|
||||
return when (this) {
|
||||
is ConeIntegerLiteralType -> getApproximatedType(expectedType)
|
||||
is ConeFlexibleType -> approximateIntegerLiteralBounds(expectedType)
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
|
||||
fun ConeKotlinType.approximateIntegerLiteralTypeOrNull(expectedType: ConeKotlinType? = null): ConeKotlinType? =
|
||||
(this as? ConeIntegerLiteralType)?.getApproximatedType(expectedType)
|
||||
private fun ConeFlexibleType.approximateIntegerLiteralBounds(expectedType: ConeKotlinType? = null): ConeFlexibleType {
|
||||
val newLowerBound = lowerBound.approximateIntegerLiteralType(expectedType)
|
||||
val newUpperBound = upperBound.approximateIntegerLiteralType(expectedType)
|
||||
|
||||
if (newLowerBound !== lowerBound || newUpperBound !== upperBound) {
|
||||
return ConeFlexibleType(
|
||||
newLowerBound.lowerBoundIfFlexible(),
|
||||
newUpperBound.upperBoundIfFlexible()
|
||||
)
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
private fun ConeClassLikeType.withNullability(nullability: ConeNullability): ConeClassLikeType {
|
||||
if (nullability == this.nullability) return this
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM, JVM_IR, ANDROID, ANDROID_IR
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// WITH_RUNTIME
|
||||
// FULL_JDK
|
||||
|
||||
// This test fails on FE 1.0, but works in production compiler (see KT-49191):
|
||||
// Caused by: java.lang.AssertionError: Lower bound Function<in (String..String?), out (IntegerLiteralType[Int,Long,Byte,Short]..IntegerLiteralType[Int,Long,Byte,Short]?)> of a flexible type must be a subtype of the upper bound Function<in (String..String?), out (IntegerLiteralType[Int,Long,Byte,Short]..IntegerLiteralType[Int,Long,Byte,Short]?)>?
|
||||
// at org.jetbrains.kotlin.types.FlexibleTypeImpl.runAssertions(flexibleTypes.kt:105)
|
||||
fun box(): String {
|
||||
val x = Comparator.comparing { x: String ->
|
||||
1
|
||||
}
|
||||
|
||||
if (x.compare("O", "K") != 0) return "fail"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -16246,6 +16246,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/fir/Fir2IrClassifierStorage.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("flexibleIntegerLiterals.kt")
|
||||
public void testFlexibleIntegerLiterals() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("incorrectBytecodeWithEnhancedNullability.kt")
|
||||
public void testIncorrectBytecodeWithEnhancedNullability() throws Exception {
|
||||
|
||||
+6
@@ -16336,6 +16336,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/fir/Fir2IrClassifierStorage.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("flexibleIntegerLiterals.kt")
|
||||
public void testFlexibleIntegerLiterals() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitNothingInDelegate.kt")
|
||||
public void testImplicitNothingInDelegate() throws Exception {
|
||||
|
||||
+5
@@ -13349,6 +13349,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Fir extends AbstractLightAnalysisModeTest {
|
||||
@TestMetadata("flexibleIntegerLiterals.kt")
|
||||
public void ignoreFlexibleIntegerLiterals() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("SuspendExtension.kt")
|
||||
public void ignoreSuspendExtension() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/SuspendExtension.kt");
|
||||
|
||||
Reference in New Issue
Block a user