Drop deprecations: *Raw functions.

This commit is contained in:
Ilya Gorbunov
2016-01-16 17:06:45 +03:00
parent d1a5988bfc
commit ef0d998fbc
6 changed files with 0 additions and 385 deletions
-62
View File
@@ -436,26 +436,6 @@ public operator fun ShortArray.contains(element: Short): Boolean {
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("contains(element as T)"))
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
public operator fun <T> Array<out T>.contains(element: T): Boolean {
return contains(element as T)
}
/**
* Returns `true` if [element] is found in the array.
* Allows to overcome type-safety restriction of `contains` that requires to pass an element of type `T`.
*/
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("contains(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> Array<out T>.containsRaw(element: Any?): Boolean {
return contains(element as Any?)
}
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
*/
@@ -1319,17 +1299,6 @@ public fun ShortArray.indexOf(element: Short): Int {
return -1
}
/**
* Returns first index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as T)"))
@kotlin.jvm.JvmName("indexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Array<out T>.indexOf(element: T): Int {
return indexOf(element as T)
}
/**
* Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.
*/
@@ -1546,16 +1515,6 @@ public inline fun ShortArray.indexOfLast(predicate: (Short) -> Boolean): Int {
return -1
}
/**
* Returns first index of [element], or -1 if the array does not contain element.
* Allows to overcome type-safety restriction of `indexOf` that requires to pass an element of type `T`.
*/
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> Array<out T>.indexOfRaw(element: Any?): Int {
return indexOf(element as Any?)
}
/**
* Returns the last element.
* @throws [NoSuchElementException] if the array is empty.
@@ -1870,27 +1829,6 @@ public fun ShortArray.lastIndexOf(element: Short): Int {
return -1
}
/**
* Returns last index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as T)"))
@kotlin.jvm.JvmName("lastIndexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Array<out T>.lastIndexOf(element: T): Int {
return lastIndexOf(element as T)
}
/**
* Returns last index of [element], or -1 if the array does not contain element.
* Allows to overcome type-safety restriction of `lastIndexOf` that requires to pass an element of type `T`.
*/
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> Array<out T>.lastIndexOfRaw(element: Any?): Int {
return lastIndexOf(element as Any?)
}
/**
* Returns the last element, or `null` if the array is empty.
*/
@@ -62,26 +62,6 @@ public operator fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains(ele
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("contains(element as T)"))
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
public operator fun <T> Iterable<T>.contains(element: T): Boolean {
return contains(element as T)
}
/**
* Returns `true` if [element] is found in the collection.
* Allows to overcome type-safety restriction of `contains` that requires to pass an element of type `T`.
*/
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("contains(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun Iterable<*>.containsRaw(element: Any?): Boolean {
return contains(element as Any?)
}
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.
*/
@@ -279,28 +259,6 @@ public fun <@kotlin.internal.OnlyInputTypes T> List<T>.indexOf(element: T): Int
return indexOf(element)
}
/**
* Returns first index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as T)"))
@kotlin.jvm.JvmName("indexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Iterable<T>.indexOf(element: T): Int {
return indexOf(element as T)
}
/**
* Returns first index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("List and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as T)"))
@kotlin.jvm.JvmName("indexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> List<T>.indexOf(element: T): Int {
return indexOf(element as T)
}
/**
* Returns index of the first element matching the given [predicate], or -1 if the collection does not contain such element.
*/
@@ -352,26 +310,6 @@ public inline fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int {
return -1
}
/**
* Returns first index of [element], or -1 if the collection does not contain element.
* Allows to overcome type-safety restriction of `indexOf` that requires to pass an element of type `T`.
*/
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun Iterable<*>.indexOfRaw(element: Any?): Int {
return indexOf(element as Any?)
}
/**
* Returns first index of [element], or -1 if the list does not contain element.
* Allows to overcome type-safety restriction of `indexOf` that requires to pass an element of type `T`.
*/
@Deprecated("List and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> List<T>.indexOfRaw(element: Any?): Int {
return (this as List<Any?>).indexOf(element)
}
/**
* Returns the last element.
* @throws [NoSuchElementException] if the collection is empty.
@@ -459,48 +397,6 @@ public fun <@kotlin.internal.OnlyInputTypes T> List<T>.lastIndexOf(element: T):
return lastIndexOf(element)
}
/**
* Returns last index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as T)"))
@kotlin.jvm.JvmName("lastIndexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Iterable<T>.lastIndexOf(element: T): Int {
return lastIndexOf(element as T)
}
/**
* Returns last index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("List and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as T)"))
@kotlin.jvm.JvmName("lastIndexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> List<T>.lastIndexOf(element: T): Int {
return lastIndexOf(element as T)
}
/**
* Returns last index of [element], or -1 if the collection does not contain element.
* Allows to overcome type-safety restriction of `lastIndexOf` that requires to pass an element of type `T`.
*/
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun Iterable<*>.lastIndexOfRaw(element: Any?): Int {
return lastIndexOf(element as Any?)
}
/**
* Returns last index of [element], or -1 if the list does not contain element.
* Allows to overcome type-safety restriction of `lastIndexOf` that requires to pass an element of type `T`.
*/
@Deprecated("List and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> List<T>.lastIndexOfRaw(element: Any?): Int {
return (this as List<Any?>).lastIndexOf(element)
}
/**
* Returns the last element, or `null` if the collection is empty.
*/
@@ -20,26 +20,6 @@ public operator fun <@kotlin.internal.OnlyInputTypes T> Sequence<T>.contains(ele
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("contains(element as T)"))
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
public operator fun <T> Sequence<T>.contains(element: T): Boolean {
return contains(element as T)
}
/**
* Returns `true` if [element] is found in the sequence.
* Allows to overcome type-safety restriction of `contains` that requires to pass an element of type `T`.
*/
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("contains(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun Sequence<*>.containsRaw(element: Any?): Boolean {
return contains(element as Any?)
}
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this sequence.
*/
@@ -144,17 +124,6 @@ public fun <@kotlin.internal.OnlyInputTypes T> Sequence<T>.indexOf(element: T):
return -1
}
/**
* Returns first index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as T)"))
@kotlin.jvm.JvmName("indexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Sequence<T>.indexOf(element: T): Int {
return indexOf(element as T)
}
/**
* Returns index of the first element matching the given [predicate], or -1 if the sequence does not contain such element.
*/
@@ -182,16 +151,6 @@ public inline fun <T> Sequence<T>.indexOfLast(predicate: (T) -> Boolean): Int {
return lastIndex
}
/**
* Returns first index of [element], or -1 if the sequence does not contain element.
* Allows to overcome type-safety restriction of `indexOf` that requires to pass an element of type `T`.
*/
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun Sequence<*>.indexOfRaw(element: Any?): Int {
return indexOf(element as Any?)
}
/**
* Returns the last element.
* @throws [NoSuchElementException] if the sequence is empty.
@@ -237,27 +196,6 @@ public fun <@kotlin.internal.OnlyInputTypes T> Sequence<T>.lastIndexOf(element:
return lastIndex
}
/**
* Returns last index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as T)"))
@kotlin.jvm.JvmName("lastIndexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Sequence<T>.lastIndexOf(element: T): Int {
return lastIndexOf(element as T)
}
/**
* Returns last index of [element], or -1 if the sequence does not contain element.
* Allows to overcome type-safety restriction of `lastIndexOf` that requires to pass an element of type `T`.
*/
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun Sequence<*>.lastIndexOfRaw(element: Any?): Int {
return lastIndexOf(element as Any?)
}
/**
* Returns the last element, or `null` if the sequence is empty.
*/
@@ -111,15 +111,6 @@ public operator fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.contain
*/
public operator fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.get(key: K): V? = (this as Map<K, V>).get(key)
/**
* Returns the value corresponding to the given [key], or `null` if such a key is not present in the map.
*
* Allows to overcome type-safety restriction of `get` that requires to pass a key of type `K`.
*/
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Map and key have incompatible types. Upcast key to Any? if you're sure.", ReplaceWith("get(key as Any?)"))
public inline fun <K, V> Map<K, V>.getRaw(key: Any?): V? = get(key)
/**
* Returns `true` if the map contains the specified [key].
*
@@ -127,10 +118,6 @@ public inline fun <K, V> Map<K, V>.getRaw(key: Any?): V? = get(key)
*/
public fun <@kotlin.internal.OnlyInputTypes K> Map<out K, *>.containsKey(key: K): Boolean = (this as Map<K, *>).containsKey(key)
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Map and key have incompatible types. Upcast key to Any? if you're sure.", ReplaceWith("containsKey(key as Any?)"))
public inline fun <K> Map<K, *>.containsKeyRaw(key: Any?): Boolean = containsKey(key)
/**
* Returns `true` if the map maps one or more keys to the specified [value].
*
@@ -138,10 +125,6 @@ public inline fun <K> Map<K, *>.containsKeyRaw(key: Any?): Boolean = containsKey
*/
public fun <K, @kotlin.internal.OnlyInputTypes V> Map<K, V>.containsValue(value: V): Boolean = this.containsValue(value)
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Map and value have incompatible types. Upcast value to Any? if you're sure.", ReplaceWith("containsValue(value as Any?)"))
public inline fun <K> Map<K, *>.containsValueRaw(value: Any?): Boolean = containsValue(value)
/**
* Removes the specified key and its corresponding value from this map.
@@ -269,15 +252,6 @@ public inline fun <K, V, R, C : MutableMap<R, V>> Map<K, V>.mapKeysTo(destinatio
return destination
}
/**
* Puts all the given [pairs] into this [MutableMap] with the first component in the pair being the key and the second the value.
*/
@kotlin.jvm.JvmName("putAllVararg")
@Deprecated("Use an overload without vararg", ReplaceWith("putAll(pairs)"))
public fun <K, V> MutableMap<K, V>.putAll(vararg pairs: Pair<K, V>): Unit {
putAll(pairs)
}
/**
* Puts all the given [pairs] into this [MutableMap] with the first component in the pair being the key and the second the value.
*/
@@ -12,15 +12,6 @@ import java.util.*
*/
public fun <@kotlin.internal.OnlyInputTypes T> Collection<T>.containsAll(elements: Collection<T>): Boolean = this.containsAll(elements)
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Collections have incompatible types. Upcast either to Collection<Any?> if you're sure.", ReplaceWith("containsAll<Any?>(elements)"))
public inline fun Collection<*>.containsAllRaw(elements: Collection<Any?>): Boolean = containsAll(elements)
@Deprecated("Collections have incompatible types. Upcast either to Collection<Any?> if you're sure.", ReplaceWith("containsAll<Any?>(elements)"))
@kotlin.jvm.JvmName("containsAllOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
public fun <E> Collection<E>.containsAll(elements: Collection<Any?>): Boolean = containsAll(elements)
/**
* Removes a single instance of the specified element from this
* collection, if it is present.
@@ -31,15 +22,6 @@ public fun <E> Collection<E>.containsAll(elements: Collection<Any?>): Boolean =
*/
public fun <@kotlin.internal.OnlyInputTypes T> MutableCollection<out T>.remove(element: T): Boolean = (this as MutableCollection<T>).remove(element)
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("remove(element as Any?)"))
public inline fun <E> MutableCollection<E>.removeRaw(element: Any?): Boolean = remove(element)
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("remove(element as T)"))
@kotlin.jvm.JvmName("removeAny")
@kotlin.internal.LowPriorityInOverloadResolution
public fun <T> MutableCollection<out T>.remove(element: T): Boolean = remove(element)
/**
* Removes all of this collection's elements that are also contained in the specified collection.
@@ -49,15 +31,6 @@ public fun <T> MutableCollection<out T>.remove(element: T): Boolean = remove(ele
*/
public fun <@kotlin.internal.OnlyInputTypes T> MutableCollection<out T>.removeAll(elements: Collection<T>): Boolean = (this as MutableCollection<T>).removeAll(elements)
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Collections have incompatible types. Upcast elements to Collection<Any?> if you're sure.", ReplaceWith("removeAll<Any?>(elements)"))
public inline fun <E> MutableCollection<E>.removeAllRaw(elements: Collection<Any?>): Boolean = removeAll(elements)
@Deprecated("Collections have incompatible types. Upcast elements to Collection<Any?> if you're sure.", ReplaceWith("removeAll<Any?>(elements)"))
@kotlin.jvm.JvmName("removeAllOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
public fun <E> MutableCollection<E>.removeAll(elements: Collection<Any?>): Boolean = removeAll(elements)
/**
* Retains only the elements in this collection that are contained in the specified collection.
*
@@ -67,15 +40,6 @@ public fun <E> MutableCollection<E>.removeAll(elements: Collection<Any?>): Boole
*/
public fun <@kotlin.internal.OnlyInputTypes T> MutableCollection<out T>.retainAll(elements: Collection<T>): Boolean = (this as MutableCollection<T>).retainAll(elements)
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Collections have incompatible types. Upcast elements to Collection<Any?> if you're sure.", ReplaceWith("retainAll<Any?>(elements)"))
public inline fun <E> MutableCollection<E>.retainAllRaw(elements: Collection<Any?>): Boolean = retainAll(elements)
@Deprecated("Collections have incompatible types. Upcast elements to Collection<Any?> if you're sure.", ReplaceWith("retainAll<Any?>(elements)"))
@kotlin.jvm.JvmName("retainAllOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
public fun <E> MutableCollection<E>.retainAll(elements: Collection<Any?>): Boolean = retainAll(elements as Collection<Any?>)
@Deprecated("Use operator 'get' instead", ReplaceWith("this[index]"))
public fun CharSequence.charAt(index: Int): Char = this[index]
@@ -102,18 +66,6 @@ public fun <E> MutableList<E>.remove(index: Int): E = removeAt(index)
@Deprecated("Use property 'length' instead.", ReplaceWith("length"))
public fun CharSequence.length(): Int = length
@Deprecated("Map and key have incompatible types. Upcast key to Any? if you're sure.", ReplaceWith("get(key as K)"))
@kotlin.internal.LowPriorityInOverloadResolution
public inline operator fun <K, V> Map<out K, V>.get(key: K): V? = get(key)
@Deprecated("Map and key have incompatible types. Upcast key to Any? if you're sure.", ReplaceWith("containsKey(key as K)"))
@kotlin.internal.LowPriorityInOverloadResolution
public inline fun <K, V> Map<out K, V>.containsKey(key: K): Boolean = containsKey(key)
@Deprecated("Map and value have incompatible types. Upcast value to Any? if you're sure.", ReplaceWith("containsValue(value as V)"))
@kotlin.internal.LowPriorityInOverloadResolution
public inline fun <K, V> Map<K, V>.containsValue(value: V): Boolean = containsValue(value as Any?)
@Deprecated("Use property 'keys' instead.", ReplaceWith("keys"))
public inline fun <K, V> Map<K, V>.keySet(): Set<K> = keys
@@ -29,33 +29,6 @@ fun elements(): List<GenericFunction> {
}
templates add f("contains(element: T)") {
operator(true)
only(Iterables, Sequences, ArraysOfObjects)
doc { "Returns `true` if [element] is found in the collection." }
returns("Boolean")
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure.", "contains(element as T)") } }
annotations("""
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
""".trimIndent())
}
templates add f("containsRaw(element: Any?)") {
only(Iterables, Sequences, ArraysOfObjects)
doc { f ->
"""
Returns `true` if [element] is found in the ${f.collection}.
Allows to overcome type-safety restriction of `contains` that requires to pass an element of type `T`.
"""
}
receiverAsterisk(Iterables, Sequences) { true }
inline(true)
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure.", "contains(element as Any?)") } }
annotations("""@Suppress("NOTHING_TO_INLINE")""")
returns("Boolean")
}
templates add f("indexOf(element: T)") {
only(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives, Lists)
doc { f -> "Returns first index of [element], or -1 if the ${f.collection} does not contain element." }
@@ -105,34 +78,6 @@ fun elements(): List<GenericFunction> {
body(Lists) { "return indexOf(element)" }
}
templates add f("indexOf(element: T)") {
only(Iterables, Sequences, ArraysOfObjects, Lists)
doc { "Returns first index of [element], or -1 if the collection does not contain element." }
returns("Int")
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure.", "indexOf(element as T)") } }
annotations("""
@kotlin.jvm.JvmName("indexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
""".trimIndent())
}
templates add f("indexOfRaw(element: Any?)") {
only(Iterables, Sequences, ArraysOfObjects, Lists)
doc { f ->
"""
Returns first index of [element], or -1 if the ${f.collection} does not contain element.
Allows to overcome type-safety restriction of `indexOf` that requires to pass an element of type `T`.
"""
}
receiverAsterisk(Iterables, Sequences) { true }
inline(true)
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure.", "indexOf(element as Any?)") } }
annotations("""@Suppress("NOTHING_TO_INLINE")""")
returns("Int")
body(Lists) { "return (this as List<Any?>).indexOf(element)" }
}
templates add f("lastIndexOf(element: T)") {
only(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives, Lists)
doc { f -> "Returns last index of [element], or -1 if the ${f.collection} does not contain element." }
@@ -183,34 +128,6 @@ fun elements(): List<GenericFunction> {
body(Lists) { "return lastIndexOf(element)" }
}
templates add f("lastIndexOf(element: T)") {
only(Iterables, Sequences, ArraysOfObjects, Lists)
doc { "Returns last index of [element], or -1 if the collection does not contain element." }
returns("Int")
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure.", "lastIndexOf(element as T)") } }
annotations("""
@kotlin.jvm.JvmName("lastIndexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
""".trimIndent())
}
templates add f("lastIndexOfRaw(element: Any?)") {
only(Iterables, Sequences, ArraysOfObjects, Lists)
doc { f ->
"""
Returns last index of [element], or -1 if the ${f.collection} does not contain element.
Allows to overcome type-safety restriction of `lastIndexOf` that requires to pass an element of type `T`.
"""
}
receiverAsterisk(Iterables, Sequences) { true }
inline(true)
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure.", "lastIndexOf(element as Any?)") } }
annotations("""@Suppress("NOTHING_TO_INLINE")""")
returns("Int")
body(Lists) { "return (this as List<Any?>).lastIndexOf(element)" }
}
templates add f("indexOfFirst(predicate: (T) -> Boolean)") {
inline(true)