Add CharSequence.subSequence

This is done primarily for JVM interoperability, otherwise it's impossible to
inherit from CharSequence there. On JS subSequence at the moment just invokes
substring.

 #KT-5956 Fixed
This commit is contained in:
Alexander Udalov
2014-11-27 16:02:41 +03:00
parent 4d95bcfc7e
commit 8dae1b62dd
14 changed files with 64 additions and 21 deletions
@@ -0,0 +1,15 @@
package foo
fun box(): String {
val kotlin: String = "kotlin"
if (kotlin.subSequence(0, kotlin.length()) != kotlin) return "Fail 0"
val kot: CharSequence = kotlin.subSequence(0, 3)
if (kot.toString() != "kot") return "Fail 1: $kot"
val tlin = (kotlin : CharSequence).subSequence(2, 6)
if (tlin.toString() != "tlin") return "Fail 2: $tlin"
return "OK"
}