[NI] Support signed-unsigned conversions for K/Native

#KT-34545 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2020-02-11 08:17:50 +03:00
parent e14e58c121
commit 0d310c0fa4
14 changed files with 179 additions and 57 deletions
@@ -1,5 +1,6 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
// !CHECK_TYPE
// !WITH_NEW_INFERENCE
// Here we mostly trying to fix behaviour in order to track changes in inference rules for unsigned types later
@@ -9,9 +10,11 @@ fun <K> select(x: K, y: K): K = TODO()
fun takeUByte(u: UByte) {}
fun foo() {
select(1, 1u) checkType { _<Comparable<*>>() }
takeUByte(<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>id(1)<!>)
<!NI;TYPE_MISMATCH!>select<!>(1, 1u) checkType { <!NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Comparable<*>>() }
takeUByte(<!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>id(1)<!>)
1 <!NONE_APPLICABLE!>+<!> 1u
(1u + <!SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED!>1<!>) checkType { _<UInt>() }
id<UInt>(<!SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED!>1<!>)
}
@@ -1,4 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !WITH_NEW_INFERENCE
fun takeUByte(u: UByte) {}
fun takeUShort(u: UShort) {}
@@ -26,7 +27,7 @@ fun test() {
takeUInt(<!SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED!>1<!>)
takeULong(<!SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED!>1<!>)
takeULong(<!INT_LITERAL_OUT_OF_RANGE!>18446744073709551615<!>)
takeULong(<!INT_LITERAL_OUT_OF_RANGE, NI;TYPE_MISMATCH!>18446744073709551615<!>)
takeULong(<!SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED!>1844674407370955161<!>)
takeULong(18446744073709551615u)