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 b564e8deb34..6a3d0fd71fc 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
@@ -19877,6 +19877,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/numbers/kt47447.kt");
}
+ @Test
+ @TestMetadata("kt47729.kt")
+ public void testKt47729() throws Exception {
+ runTest("compiler/testData/diagnostics/tests/numbers/kt47729.kt");
+ }
+
@Test
@TestMetadata("kt47729_parenthesis.kt")
public void testKt47729_parenthesis() throws Exception {
diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java
index 66000e29c9c..e83a65d0414 100644
--- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java
+++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java
@@ -19877,6 +19877,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/numbers/kt47447.kt");
}
+ @Test
+ @TestMetadata("kt47729.kt")
+ public void testKt47729() throws Exception {
+ runTest("compiler/testData/diagnostics/tests/numbers/kt47729.kt");
+ }
+
@Test
@TestMetadata("kt47729_parenthesis.kt")
public void testKt47729_parenthesis() throws Exception {
diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/NewSchemeOfIntegerOperatorResolutionChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/NewSchemeOfIntegerOperatorResolutionChecker.kt
index 1867ce4b3fd..0e7a5808028 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/NewSchemeOfIntegerOperatorResolutionChecker.kt
+++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/NewSchemeOfIntegerOperatorResolutionChecker.kt
@@ -23,6 +23,8 @@ import org.jetbrains.kotlin.resolve.constants.IntegerLiteralTypeConstructor
import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.types.lowerIfFlexible
+import org.jetbrains.kotlin.types.typeUtil.isPrimitiveNumberOrNullableType
+import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
object NewSchemeOfIntegerOperatorResolutionChecker : CallChecker {
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
@@ -34,6 +36,9 @@ object NewSchemeOfIntegerOperatorResolutionChecker : CallChecker {
} else {
valueParameter.type
}.unwrap().lowerIfFlexible()
+ if (!expectedType.isPrimitiveNumberOrNullableType()) {
+ continue
+ }
for (argument in arguments.arguments) {
val expression = KtPsiUtil.deparenthesize(argument.getArgumentExpression()) ?: continue
val compileTimeValue =
@@ -50,7 +55,7 @@ object NewSchemeOfIntegerOperatorResolutionChecker : CallChecker {
val valueTypeConstructor = compileTimeValue.unknownIntegerType.constructor as? IntegerLiteralTypeConstructor ?: continue
val approximatedType = valueTypeConstructor.getApproximatedType()
- if (approximatedType != expectedType) {
+ if (approximatedType.constructor != expectedType.constructor) {
context.trace.report(Errors.INTEGER_OPERATOR_RESOLVE_WILL_CHANGE.on(expression, approximatedType))
}
}
diff --git a/compiler/testData/diagnostics/tests/annotations/parameters/expressions/maxValueInt.kt b/compiler/testData/diagnostics/tests/annotations/parameters/expressions/maxValueInt.kt
index 8260cf979a8..de017572ec4 100644
--- a/compiler/testData/diagnostics/tests/annotations/parameters/expressions/maxValueInt.kt
+++ b/compiler/testData/diagnostics/tests/annotations/parameters/expressions/maxValueInt.kt
@@ -11,8 +11,8 @@ annotation class Ann(
@Ann(
p1 = java.lang.Integer.MAX_VALUE + 1,
p2 = 1 + 1,
- p3 = java.lang.Integer.MAX_VALUE + 1,
- p4 = 1.toInt() + 1.toInt(),
+ p3 = java.lang.Integer.MAX_VALUE + 1,
+ p4 = 1.toInt() + 1.toInt(),
p5 = 1.toInt() + 1.toInt()
) class MyClass
diff --git a/compiler/testData/diagnostics/tests/numbers/kt47729.fir.kt b/compiler/testData/diagnostics/tests/numbers/kt47729.fir.kt
new file mode 100644
index 00000000000..260e2439cff
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/numbers/kt47729.fir.kt
@@ -0,0 +1,22 @@
+// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
+// ISSUE: Kt-47447, KT-47729
+
+fun takeLong(value : Long) {}
+fun takeInt(value : Int) {}
+fun takeAny(value : Any) {}
+fun takeLongX(value : Long?) {}
+fun takeIntX(value : Int?) {}
+fun takeAnyX(value : Any?) {}
+fun takeGeneric(value : A) {}
+fun takeGenericX(value : A?) {}
+
+fun test_1() {
+ takeLong(1 + 1) // warning
+ takeInt(1 + 1) // ok
+ takeAny(1 + 1) // ok
+ takeLongX(1 + 1) // warning
+ takeIntX(1 + 1) // ok
+ takeAnyX(1 + 1) // ok
+ takeGeneric(1 + 1) // ok
+ takeGenericX(1 + 1) // ok
+}
diff --git a/compiler/testData/diagnostics/tests/numbers/kt47729.kt b/compiler/testData/diagnostics/tests/numbers/kt47729.kt
new file mode 100644
index 00000000000..1c1af8f4819
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/numbers/kt47729.kt
@@ -0,0 +1,22 @@
+// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
+// ISSUE: Kt-47447, KT-47729
+
+fun takeLong(value : Long) {}
+fun takeInt(value : Int) {}
+fun takeAny(value : Any) {}
+fun takeLongX(value : Long?) {}
+fun takeIntX(value : Int?) {}
+fun takeAnyX(value : Any?) {}
+fun takeGeneric(value : A) {}
+fun takeGenericX(value : A?) {}
+
+fun test_1() {
+ takeLong(1 + 1) // warning
+ takeInt(1 + 1) // ok
+ takeAny(1 + 1) // ok
+ takeLongX(1 + 1) // warning
+ takeIntX(1 + 1) // ok
+ takeAnyX(1 + 1) // ok
+ takeGeneric(1 + 1) // ok
+ takeGenericX(1 + 1) // ok
+}
diff --git a/compiler/testData/diagnostics/tests/numbers/kt47729.txt b/compiler/testData/diagnostics/tests/numbers/kt47729.txt
new file mode 100644
index 00000000000..16895c50b1e
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/numbers/kt47729.txt
@@ -0,0 +1,11 @@
+package
+
+public fun takeAny(/*0*/ value: kotlin.Any): kotlin.Unit
+public fun takeAnyX(/*0*/ value: kotlin.Any?): kotlin.Unit
+public fun *0*/ A> takeGeneric(/*0*/ value: A): kotlin.Unit
+public fun *0*/ A> takeGenericX(/*0*/ value: A?): kotlin.Unit
+public fun takeInt(/*0*/ value: kotlin.Int): kotlin.Unit
+public fun takeIntX(/*0*/ value: kotlin.Int?): kotlin.Unit
+public fun takeLong(/*0*/ value: kotlin.Long): kotlin.Unit
+public fun takeLongX(/*0*/ value: kotlin.Long?): kotlin.Unit
+public fun test_1(): kotlin.Unit
diff --git a/compiler/testData/diagnostics/tests/unsignedTypes/conversions/signedToUnsignedConversionWithExpectedType.kt b/compiler/testData/diagnostics/tests/unsignedTypes/conversions/signedToUnsignedConversionWithExpectedType.kt
index b3514dc6dfa..bf30f8146d0 100644
--- a/compiler/testData/diagnostics/tests/unsignedTypes/conversions/signedToUnsignedConversionWithExpectedType.kt
+++ b/compiler/testData/diagnostics/tests/unsignedTypes/conversions/signedToUnsignedConversionWithExpectedType.kt
@@ -33,7 +33,7 @@ fun test() {
takeUInt(Int.MAX_VALUE * 2)
takeUInt(4294967294)
- takeUBytes(1, 2, 255, 256, 0, -1, 40 + 2)
+ takeUBytes(1, 2, 255, 256, 0, -1, 40 + 2)
takeUInt(1.myPlus(2))
diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/jsCode/argumentIsLiteral.kt b/compiler/testData/diagnostics/testsWithJsStdLib/jsCode/argumentIsLiteral.kt
index eadb4f2ac9b..827b60773ac 100644
--- a/compiler/testData/diagnostics/testsWithJsStdLib/jsCode/argumentIsLiteral.kt
+++ b/compiler/testData/diagnostics/testsWithJsStdLib/jsCode/argumentIsLiteral.kt
@@ -9,7 +9,7 @@ fun test() {
js((b))
js(("c"))
js(3)
- js(3 + 2)
+ js(3 + 2)
js(1.0f)
js(true)
js("$a")
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 369b91952f5..3e626689ae6 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
@@ -19883,6 +19883,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/numbers/kt47447.kt");
}
+ @Test
+ @TestMetadata("kt47729.kt")
+ public void testKt47729() throws Exception {
+ runTest("compiler/testData/diagnostics/tests/numbers/kt47729.kt");
+ }
+
@Test
@TestMetadata("kt47729_parenthesis.kt")
public void testKt47729_parenthesis() throws Exception {
diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java
index 0e704459e3c..b2157653312 100644
--- a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java
+++ b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java
@@ -19877,6 +19877,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/numbers/kt47447.kt");
}
+ @Test
+ @TestMetadata("kt47729.kt")
+ public void testKt47729() throws Exception {
+ runTest("compiler/testData/diagnostics/tests/numbers/kt47729.kt");
+ }
+
@Test
@TestMetadata("kt47729_parenthesis.kt")
public void testKt47729_parenthesis() throws Exception {