Discriminate unsigned types in overload resolution

#KT-24717 Fixed
 Relates to #KT-25996 and #KT-25997
This commit is contained in:
Mikhail Zarechenskiy
2018-08-08 04:21:23 +03:00
parent be38263fc7
commit 1a511166cc
3 changed files with 73 additions and 12 deletions
@@ -0,0 +1,39 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !CHECK_TYPE
fun foo(x: Int): Int = 0
@JvmName("fooUInt")
fun foo(x: UInt): String = ""
fun foo(x: UByte): String = ""
fun foo(x: UShort): String = ""
fun foo(x: ULong): String = ""
fun fooByte(x: Byte): Int = 0
@JvmName("fooUByte")
fun fooByte(x: UByte): String = ""
fun fooShort(x: Short): Int = 0
@JvmName("fooUByte")
fun fooShort(x: UShort): String = ""
fun fooLong(x: Long): Int = 0
@JvmName("fooULong")
fun fooLong(x: ULong): String = ""
fun test() {
foo(1) checkType { _<Int>() }
foo(1u) checkType { _<String>() }
foo(2147483648) checkType { _<String>() }
foo(<!INTEGER_OVERFLOW!>2147483647 + 1<!>) checkType { _<Int>() }
fooByte(1) checkType { _<Int>() }
fooByte(1u) checkType { _<String>() }
fooShort(1) checkType { _<Int>() }
fooShort(1u) checkType { _<String>() }
fooLong(1) checkType { _<Int>() }
fooLong(1u) checkType { _<String>() }
}
@@ -0,0 +1,14 @@
package
public fun foo(/*0*/ x: kotlin.Int): kotlin.Int
public fun foo(/*0*/ x: kotlin.UByte): kotlin.String
@kotlin.jvm.JvmName(name = "fooUInt") public fun foo(/*0*/ x: kotlin.UInt): kotlin.String
public fun foo(/*0*/ x: kotlin.ULong): kotlin.String
public fun foo(/*0*/ x: kotlin.UShort): kotlin.String
public fun fooByte(/*0*/ x: kotlin.Byte): kotlin.Int
@kotlin.jvm.JvmName(name = "fooUByte") public fun fooByte(/*0*/ x: kotlin.UByte): kotlin.String
public fun fooLong(/*0*/ x: kotlin.Long): kotlin.Int
@kotlin.jvm.JvmName(name = "fooULong") public fun fooLong(/*0*/ x: kotlin.ULong): kotlin.String
public fun fooShort(/*0*/ x: kotlin.Short): kotlin.Int
@kotlin.jvm.JvmName(name = "fooUByte") public fun fooShort(/*0*/ x: kotlin.UShort): kotlin.String
public fun test(): kotlin.Unit