diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 1820ff3c8b8..d4f76c47a07 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -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 { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt index 04ab0166a94..4b571612eb0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt @@ -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() } diff --git a/compiler/testData/diagnostics/tests/numbers/kt41679.fir.kt b/compiler/testData/diagnostics/tests/numbers/kt41679.fir.kt new file mode 100644 index 00000000000..1488678ac9c --- /dev/null +++ b/compiler/testData/diagnostics/tests/numbers/kt41679.fir.kt @@ -0,0 +1,12 @@ +// WITH_STDLIB +// ISSUE: KT-41679 + +fun test_1() { + var y = & java.io.Serializable>")!>mutableListOf("MH", 19, true) + y[0] = "value4" +} + +fun test_2(x: Int) { + var y = & java.io.Serializable>")!>mutableListOf("MH", x, true) + y[0] = "value4" +} diff --git a/compiler/testData/diagnostics/tests/numbers/kt41679.kt b/compiler/testData/diagnostics/tests/numbers/kt41679.kt new file mode 100644 index 00000000000..c53efdafd39 --- /dev/null +++ b/compiler/testData/diagnostics/tests/numbers/kt41679.kt @@ -0,0 +1,12 @@ +// WITH_STDLIB +// ISSUE: KT-41679 + +fun test_1() { + var y = & java.io.Serializable}>")!>mutableListOf("MH", 19, true) + y[0] = "value4" +} + +fun test_2(x: Int) { + var y = & java.io.Serializable}>")!>mutableListOf("MH", x, true) + y[0] = "value4" +} diff --git a/compiler/testData/diagnostics/tests/numbers/kt41679.txt b/compiler/testData/diagnostics/tests/numbers/kt41679.txt new file mode 100644 index 00000000000..0a8022248c8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/numbers/kt41679.txt @@ -0,0 +1,5 @@ +package + +public fun test_1(): kotlin.Unit +public fun test_2(/*0*/ x: kotlin.Int): kotlin.Unit + diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.txt index 24c31fabc9b..ac6856a900e 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.txt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.txt @@ -1,7 +1,7 @@ package public val test1: C /* = Cons */ -public val test2: Cons +public val test2: C /* = Cons */ public val test23: C2 /* = MapLike */ public val test234: C2<(C2 /* = MapLike */..C2? /* = MapLike? */)> /* = MapLike<(C2 /* = MapLike */..C2? /* = MapLike? */)> */ diff --git a/compiler/testData/diagnostics/tests/typealias/wrongNumberOfArgumentsInTypeAliasConstructor.ni.txt b/compiler/testData/diagnostics/tests/typealias/wrongNumberOfArgumentsInTypeAliasConstructor.ni.txt index a008f589c3e..be9b0aa0ebb 100644 --- a/compiler/testData/diagnostics/tests/typealias/wrongNumberOfArgumentsInTypeAliasConstructor.ni.txt +++ b/compiler/testData/diagnostics/tests/typealias/wrongNumberOfArgumentsInTypeAliasConstructor.ni.txt @@ -2,7 +2,7 @@ package public val test0: P /* = Pair */ public val test0p2: P2 /* = Pair */ -public val test0p2a: Pair +public val test0p2a: Pair public val test0pr: PR /* = Pair */ public val test1: P /* = Pair */ public val test1p2: P2 /* = Pair */ @@ -13,7 +13,7 @@ public val test2pr: PR /* = Pair /* = Pair */ public val test3: P /* = Pair */ public val test3p2: P2 /* = Pair */ -public val test3pr: Pair +public val test3pr: Pair public val testMP0: MP /* = MyPair */ public val testMP1: MP /* = MyPair */ public val testMP2: MP /* = MyPair */ diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index c1f60529aa7..6c3b9ea5a79 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -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 { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt b/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt index 4575fee58ee..589f024c610 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt @@ -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? {