Don't allow coercing receivers from signed to unsigned constants
This commit is contained in:
+1
-1
@@ -429,7 +429,7 @@ private fun KotlinResolutionCandidate.resolveKotlinArgument(
|
|||||||
val unsubstitutedExpectedType = conversionDataBeforeSubtyping?.convertedType ?: candidateExpectedType
|
val unsubstitutedExpectedType = conversionDataBeforeSubtyping?.convertedType ?: candidateExpectedType
|
||||||
val expectedType = unsubstitutedExpectedType?.let { prepareExpectedType(it) }
|
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)
|
val convertedConstant = resolutionCallbacks.convertSignedConstantToUnsigned(argument)
|
||||||
if (convertedConstant != null) {
|
if (convertedConstant != null) {
|
||||||
resolvedCall.registerArgumentWithConstantConversion(argument, convertedConstant)
|
resolvedCall.registerArgumentWithConstantConversion(argument, convertedConstant)
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
fun UInt.fUInt() {}
|
||||||
|
fun UByte.fUByte() {}
|
||||||
|
fun UShort.fUShort() {}
|
||||||
|
fun ULong.fULong() {}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>fUInt<!>()
|
||||||
|
1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>fUByte<!>()
|
||||||
|
1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>fUShort<!>()
|
||||||
|
1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>fULong<!>()
|
||||||
|
|
||||||
|
3000000000 until <!CONSTANT_EXPECTED_TYPE_MISMATCH!>3000000004UL<!>
|
||||||
|
0 until <!CONSTANT_EXPECTED_TYPE_MISMATCH!>10u<!>
|
||||||
|
}
|
||||||
+7
@@ -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
|
||||||
+5
@@ -110,6 +110,11 @@ public class DiagnosticsWithUnsignedTypesGenerated extends AbstractDiagnosticsWi
|
|||||||
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/inferenceForSignedAndUnsignedTypes.kt");
|
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")
|
@TestMetadata("overloadResolutionForSignedAndUnsignedTypes.kt")
|
||||||
public void testOverloadResolutionForSignedAndUnsignedTypes() throws Exception {
|
public void testOverloadResolutionForSignedAndUnsignedTypes() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/overloadResolutionForSignedAndUnsignedTypes.kt");
|
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/overloadResolutionForSignedAndUnsignedTypes.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user