KT-13023 Char operations throw ClassCastException for boxed Chars

Char is not a Number, so we can't use the same coercion strategy for Char members,
since it doesn't work for boxed Chars.
This commit is contained in:
Dmitry Petrov
2016-07-07 16:23:42 +03:00
parent 2ccb0caa6c
commit b0edec8449
3 changed files with 44 additions and 7 deletions
+20
View File
@@ -0,0 +1,20 @@
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val b = 'b'
val c = 'c'
assertEquals('c', b + 1)
assertEquals('a', b - 1)
assertEquals(1, c - b)
val list = listOf('b', 'a')
assertEquals('c', list[0] + 1)
assertEquals('a', list[0] - 1)
assertEquals(1, list[0] - list[1])
assertEquals(1, list[0] - 'a')
assertEquals(1, 'b' - list[1])
return "OK"
}