[NI] Assume that ILT is number type in inference

#KT-41679 Fixed
This commit is contained in:
Dmitriy Novozhilov
2021-04-05 15:46:37 +03:00
committed by TeamCityServer
parent a107e3d160
commit 99e681ec1d
9 changed files with 46 additions and 4 deletions
@@ -18957,6 +18957,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/numbers/intValuesOutOfRange.kt");
}
@Test
@TestMetadata("kt41679.kt")
public void testKt41679() throws Exception {
runTest("compiler/testData/diagnostics/tests/numbers/kt41679.kt");
}
@Test
@TestMetadata("literalReceiverWithIntegerValueType.kt")
public void testLiteralReceiverWithIntegerValueType() throws Exception {
@@ -386,6 +386,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
override fun KotlinTypeMarker.isSignedOrUnsignedNumberType(): Boolean {
require(this is ConeKotlinType)
if (this is ConeIntegerLiteralType) return true
if (this !is ConeClassLikeType) return false
return isPrimitiveNumberOrUnsignedNumberType()
}
@@ -0,0 +1,12 @@
// WITH_STDLIB
// ISSUE: KT-41679
fun test_1() {
var y = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.MutableList<kotlin.Comparable<*> & java.io.Serializable>")!>mutableListOf("MH", 19, true)<!>
y[0] = "value4"
}
fun test_2(x: Int) {
var y = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.MutableList<kotlin.Comparable<*> & java.io.Serializable>")!>mutableListOf("MH", x, true)<!>
y[0] = "value4"
}
+12
View File
@@ -0,0 +1,12 @@
// WITH_STDLIB
// ISSUE: KT-41679
fun test_1() {
var y = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.MutableList<{Comparable<*> & java.io.Serializable}>")!>mutableListOf("MH", 19, true)<!>
y[0] = "value4"
}
fun test_2(x: Int) {
var y = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.MutableList<{Comparable<*> & java.io.Serializable}>")!>mutableListOf("MH", x, true)<!>
y[0] = "value4"
}
@@ -0,0 +1,5 @@
package
public fun test_1(): kotlin.Unit
public fun test_2(/*0*/ x: kotlin.Int): kotlin.Unit
@@ -1,7 +1,7 @@
package
public val test1: C<kotlin.Int> /* = Cons<kotlin.Int> */
public val test2: Cons<out kotlin.Any?>
public val test2: C<kotlin.Number> /* = Cons<kotlin.Number> */
public val test23: C2<kotlin.Int?> /* = MapLike<kotlin.Int?> */
public val test234: C2<(C2<kotlin.Int?> /* = MapLike<kotlin.Int?> */..C2<kotlin.Int?>? /* = MapLike<kotlin.Int?>? */)> /* = MapLike<(C2<kotlin.Int?> /* = MapLike<kotlin.Int?> */..C2<kotlin.Int?>? /* = MapLike<kotlin.Int?>? */)> */
@@ -2,7 +2,7 @@ package
public val test0: P<kotlin.Int, kotlin.Int> /* = Pair<kotlin.Int, kotlin.Int> */
public val test0p2: P2<kotlin.Int> /* = Pair<kotlin.Int, kotlin.Int> */
public val test0p2a: Pair<out kotlin.Any?, out kotlin.Any?>
public val test0p2a: Pair<out kotlin.Any, out kotlin.Any>
public val test0pr: PR<kotlin.String, kotlin.Int> /* = Pair<kotlin.Int, kotlin.String> */
public val test1: P<kotlin.Int, kotlin.Int> /* = Pair<kotlin.Int, kotlin.Int> */
public val test1p2: P2<kotlin.Int> /* = Pair<kotlin.Int, kotlin.Int> */
@@ -13,7 +13,7 @@ public val test2pr: PR<kotlin.Int, kotlin.String> /* = Pair<kotlin.String, kotli
public val test2pra: PR<kotlin.String, kotlin.Int> /* = Pair<kotlin.Int, kotlin.String> */
public val test3: P<kotlin.Int, kotlin.Int> /* = Pair<kotlin.Int, kotlin.Int> */
public val test3p2: P2<kotlin.Int> /* = Pair<kotlin.Int, kotlin.Int> */
public val test3pr: Pair<out kotlin.Any?, out kotlin.Any?>
public val test3pr: Pair<out kotlin.Any, out kotlin.Any>
public val testMP0: MP<kotlin.Int> /* = MyPair<kotlin.String, kotlin.Int> */
public val testMP1: MP<kotlin.String> /* = MyPair<kotlin.String, kotlin.String> */
public val testMP2: MP<kotlin.String> /* = MyPair<kotlin.String, kotlin.String> */
@@ -18963,6 +18963,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/numbers/intValuesOutOfRange.kt");
}
@Test
@TestMetadata("kt41679.kt")
public void testKt41679() throws Exception {
runTest("compiler/testData/diagnostics/tests/numbers/kt41679.kt");
}
@Test
@TestMetadata("literalReceiverWithIntegerValueType.kt")
public void testLiteralReceiverWithIntegerValueType() throws Exception {
@@ -556,7 +556,7 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
override fun KotlinTypeMarker.isSignedOrUnsignedNumberType(): Boolean {
require(this is KotlinType)
return classicIsSignedOrUnsignedNumberType()
return classicIsSignedOrUnsignedNumberType() || constructor is IntegerLiteralTypeConstructor
}
override fun findCommonIntegerLiteralTypesSuperType(explicitSupertypes: List<SimpleTypeMarker>): SimpleTypeMarker? {