Deprecate CharSequence.size in JS

#KT-18267 Fixed
This commit is contained in:
Ilya Gorbunov
2017-07-23 00:28:29 +03:00
parent f10ea03173
commit baa6b44567
4 changed files with 4 additions and 5 deletions
+2 -1
View File
@@ -35,8 +35,9 @@ public inline fun String.match(regex: String): Array<String>? = asDynamic().matc
//native public fun String.trim(): String
//TODO: String.replace to implement effective trimLeading and trimTrailing
@Deprecated("Use length property instead.", ReplaceWith("length"), level = DeprecationLevel.WARNING) // TODO: ERROR in 1.2
@kotlin.internal.InlineOnly
public inline val CharSequence.size: Int get() = asDynamic().length
public inline val CharSequence.size: Int get() = length
@kotlin.internal.InlineOnly
internal inline fun String.nativeReplace(pattern: RegExp, replacement: String): String = asDynamic().replace(pattern, replacement)
+1 -1
View File
@@ -7,7 +7,7 @@ fun test():Any {
if (true) {
when {
false -> "1"
((a as? String)?.size ?: 0 > 0) -> a
((a as? String)?.length ?: 0 > 0) -> a
else -> "2"
}
}
@@ -22,7 +22,6 @@ fun assertEquals(expected: Any, actual: Any, s: CharSequence, whatTested: String
}
fun testString(s: String, expectedSize: Int, indexOfB: Int) {
assertEquals(expectedSize, s.size, s, "size")
assertEquals(expectedSize, s.length, s, "length")
assertEquals(expectedSize == 0, s.isEmpty(), s, "isEmpty()")
assertEquals(expectedSize != 0, s.startsWith(startsWithParam), s, "startsWith(\"$startsWithParam\")")
@@ -35,7 +34,6 @@ fun testString(s: String, expectedSize: Int, indexOfB: Int) {
}
fun testCharSequence(s: CharSequence, expectedSize: Int) {
assertEquals(expectedSize, s.size, s, "size")
assertEquals(expectedSize, s.length, s, "length")
assertEquals(expectedSize == 0, s.isEmpty(), s, "isEmpty()")
}
@@ -7,7 +7,7 @@ inline fun String.charCodeAt(i: Int): Int = asDynamic().charCodeAt(i)
fun String.myHashCode(): Int {
var hash = 0
for (i in 0..size - 1) {
for (i in 0..length - 1) {
hash = 31 * hash + charCodeAt(i)
}