Chars are not promoted to Int on comparisons

This commit is contained in:
Dmitry Petrov
2018-02-26 15:30:11 +03:00
parent 4bb6c61a5a
commit 8fbdf52d34
11 changed files with 230 additions and 3 deletions
+20
View File
@@ -0,0 +1,20 @@
operator fun Int.compareTo(c: Char) = 0
fun testOverloadedCompareToCall(x: Int, y: Char) =
x < y
fun testOverloadedCompareToCallWithSmartCast(x: Any, y: Any) =
x is Int && y is Char && x < y
fun testEqualsWithSmartCast(x: Any, y: Any) =
x is Int && y is Char && x == y
class C {
operator fun Int.compareTo(c: Char) = 0
fun testMemberExtensionCompareToCall(x: Int, y: Char) =
x < y
fun testMemberExtensionCompareToCallWithSmartCast(x: Any, y: Any) =
x is Int && y is Char && x < y
}