Provide deprecated unconstrained contains, indexOf, lastIndexOf methods for migration.

This commit is contained in:
Ilya Gorbunov
2015-10-16 19:48:05 +03:00
parent 95aac7ade6
commit fc7c008672
4 changed files with 133 additions and 0 deletions
@@ -61,6 +61,16 @@ public operator fun <T> Iterable<T>.contains(element: @kotlin.internal.NoInfer T
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
@Deprecated("Use 'containsRaw' instead.", ReplaceWith("containsRaw(element)"))
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
public operator fun <T> Iterable<T>.contains(element: T): Boolean {
return containsRaw(element)
}
/**
* 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`.
@@ -260,6 +270,17 @@ public fun <T> Iterable<T>.indexOf(element: @kotlin.internal.NoInfer T): Int {
return -1
}
/**
* Returns first index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Use 'indexOfRaw' instead.", ReplaceWith("indexOfRaw(element)"))
@kotlin.jvm.JvmName("indexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Iterable<T>.indexOf(element: T): Int {
return indexOfRaw(element)
}
/**
* Returns index of the first element matching the given [predicate], or -1 if the collection does not contain such element.
*/
@@ -409,6 +430,17 @@ public fun <T> Iterable<T>.lastIndexOf(element: @kotlin.internal.NoInfer T): Int
return lastIndex
}
/**
* Returns last index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Use 'indexOfRaw' instead.", ReplaceWith("indexOfRaw(element)"))
@kotlin.jvm.JvmName("lastIndexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Iterable<T>.lastIndexOf(element: T): Int {
return indexOfRaw(element)
}
/**
* 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`.