diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt index b203e8ea7a5..19a6decf14a 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt @@ -429,7 +429,7 @@ private fun KotlinResolutionCandidate.resolveKotlinArgument( val unsubstitutedExpectedType = conversionDataBeforeSubtyping?.convertedType ?: candidateExpectedType val expectedType = unsubstitutedExpectedType?.let { prepareExpectedType(it) } - val convertedArgument = if (expectedType != null && shouldRunConversionForConstants(expectedType)) { + val convertedArgument = if (expectedType != null && !isReceiver && shouldRunConversionForConstants(expectedType)) { val convertedConstant = resolutionCallbacks.convertSignedConstantToUnsigned(argument) if (convertedConstant != null) { resolvedCall.registerArgumentWithConstantConversion(argument, convertedConstant) diff --git a/compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/noConversionForUnsignedTypesOnReceiver.kt b/compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/noConversionForUnsignedTypesOnReceiver.kt new file mode 100644 index 00000000000..d4792add7aa --- /dev/null +++ b/compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/noConversionForUnsignedTypesOnReceiver.kt @@ -0,0 +1,14 @@ +fun UInt.fUInt() {} +fun UByte.fUByte() {} +fun UShort.fUShort() {} +fun ULong.fULong() {} + +fun test() { + 1.fUInt() + 1.fUByte() + 1.fUShort() + 1.fULong() + + 3000000000 until 3000000004UL + 0 until 10u +} diff --git a/compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/noConversionForUnsignedTypesOnReceiver.txt b/compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/noConversionForUnsignedTypesOnReceiver.txt new file mode 100644 index 00000000000..52beb93976e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/noConversionForUnsignedTypesOnReceiver.txt @@ -0,0 +1,7 @@ +package + +public fun test(): kotlin.Unit +public fun kotlin.UByte.fUByte(): kotlin.Unit +public fun kotlin.UInt.fUInt(): kotlin.Unit +public fun kotlin.ULong.fULong(): kotlin.Unit +public fun kotlin.UShort.fUShort(): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsWithUnsignedTypesGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsWithUnsignedTypesGenerated.java index 8250bc8f86c..b2297d7c45f 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsWithUnsignedTypesGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsWithUnsignedTypesGenerated.java @@ -110,6 +110,11 @@ public class DiagnosticsWithUnsignedTypesGenerated extends AbstractDiagnosticsWi runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/inferenceForSignedAndUnsignedTypes.kt"); } + @TestMetadata("noConversionForUnsignedTypesOnReceiver.kt") + public void testNoConversionForUnsignedTypesOnReceiver() throws Exception { + runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/noConversionForUnsignedTypesOnReceiver.kt"); + } + @TestMetadata("overloadResolutionForSignedAndUnsignedTypes.kt") public void testOverloadResolutionForSignedAndUnsignedTypes() throws Exception { runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/overloadResolutionForSignedAndUnsignedTypes.kt");