diff --git a/js/js.libraries/src/core/javautil.kt b/js/js.libraries/src/core/javautil.kt index 79523493918..8722d214825 100644 --- a/js/js.libraries/src/core/javautil.kt +++ b/js/js.libraries/src/core/javautil.kt @@ -18,7 +18,7 @@ public abstract class AbstractCollection() : MutableCollection { override fun iterator(): MutableIterator = noImpl override fun add(e: E): Boolean = noImpl - override fun remove(o: Any?): Boolean = noImpl + override fun remove(o: E): Boolean = noImpl override fun addAll(c: Collection): Boolean = noImpl override fun containsAll(c: Collection): Boolean = noImpl @@ -41,7 +41,7 @@ public abstract class AbstractList() : AbstractCollection(), MutableList): Boolean = noImpl - override fun remove(index: Int): E = noImpl + override fun removeAt(index: Int): E = noImpl override fun indexOf(o: Any?): Int = noImpl override fun lastIndexOf(o: Any?): Int = noImpl diff --git a/libraries/stdlib/src/kotlin/collections/MutableCollections.kt b/libraries/stdlib/src/kotlin/collections/MutableCollections.kt index d739a2221ce..870f840ad2e 100644 --- a/libraries/stdlib/src/kotlin/collections/MutableCollections.kt +++ b/libraries/stdlib/src/kotlin/collections/MutableCollections.kt @@ -22,6 +22,15 @@ public fun Map.Entry.getKey(): K = key @Deprecated("Use property `value` instead", ReplaceWith("this.value")) public fun Map.Entry.getValue(): V = value +@Deprecated("Use operator 'get' instead", ReplaceWith("this[index]")) +public fun CharSequence.charAt(index: Int): Char = this[index] + +@Deprecated("Use `removeAt` instead", ReplaceWith("this.removeAt(index)")) +public fun MutableList.remove(index: Int): E = removeAt(index) + +@Deprecated("Use explicit cast to MutableCollection instead", ReplaceWith("(this as MutableCollection).remove(o)")) +public fun MutableCollection.remove(o: Any?): Boolean = remove(o as E) + /** * Adds the specified [element] to this mutable collection. */ diff --git a/libraries/stdlib/src/kotlin/collections/ReversedViews.kt b/libraries/stdlib/src/kotlin/collections/ReversedViews.kt index bfc84efc9d4..33d667c3cb7 100644 --- a/libraries/stdlib/src/kotlin/collections/ReversedViews.kt +++ b/libraries/stdlib/src/kotlin/collections/ReversedViews.kt @@ -30,7 +30,7 @@ private open class ReversedListReadOnly(protected open val delegate: List) private class ReversedList(protected override val delegate: MutableList) : ReversedListReadOnly(delegate) { override fun clear() = delegate.clear() - override fun remove(index: Int): T = delegate.remove(index.flipIndex()) + override fun removeAt(index: Int): T = delegate.removeAt(index.flipIndex()) override fun set(index: Int, element: T): T = delegate.set(index.flipIndex(), element) override fun add(index: Int, element: T) { diff --git a/libraries/stdlib/src/kotlin/text/Strings.kt b/libraries/stdlib/src/kotlin/text/Strings.kt index efd559f7f3e..cfe44983ace 100644 --- a/libraries/stdlib/src/kotlin/text/Strings.kt +++ b/libraries/stdlib/src/kotlin/text/Strings.kt @@ -191,15 +191,6 @@ public val String.indices: IntRange public val String.lastIndex: Int get() = this.length() - 1 -/** - * Returns a character at the given index in a [CharSequence]. Allows to use the - * index operator for working with character sequences: - * ``` - * val c = charSequence[5] - * ``` - */ -public operator fun CharSequence.get(index: Int): Char = this.charAt(index) - /** * Returns `true` if this CharSequence has Unicode surrogate pair at the specified [index]. */ diff --git a/libraries/stdlib/test/collections/ReversedViewsTest.kt b/libraries/stdlib/test/collections/ReversedViewsTest.kt index d3317eec25d..5d5b171454e 100644 --- a/libraries/stdlib/test/collections/ReversedViewsTest.kt +++ b/libraries/stdlib/test/collections/ReversedViewsTest.kt @@ -157,11 +157,11 @@ class ReversedViewsTest { val original = arrayListOf(1, 2, 3, 4) val reversed = original.asReversed() - original.remove(3) + original.removeAt(3) assertEquals(listOf(1, 2, 3), original) assertEquals(listOf(3, 2, 1), reversed) - reversed.remove(2) + reversed.removeAt(2) assertEquals(listOf(2, 3), original) assertEquals(listOf(3, 2), reversed) } @@ -201,7 +201,7 @@ class ReversedViewsTest { @test fun testRemoveIOOB() { val success = try { - arrayListOf(1, 2, 3).asReversed().remove(3) + arrayListOf(1, 2, 3).asReversed().removeAt(3) true } catch(expected: IndexOutOfBoundsException) { false