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
@@ -26,6 +26,19 @@ 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(Deprecation("Use 'containsRaw' instead.", "containsRaw(element)"))
annotations("""
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
""".trimIndent())
}
templates add f("containsRaw(element: Any?)") {
only(Iterables, Sequences, ArraysOfObjects)
doc {
@@ -89,6 +102,18 @@ fun elements(): List<GenericFunction> {
}
}
templates add f("indexOf(element: T)") {
only(Iterables, Sequences, ArraysOfObjects)
doc { "Returns first index of [element], or -1 if the collection does not contain element." }
returns("Int")
deprecate(Deprecation("Use 'indexOfRaw' instead.", "indexOfRaw(element)"))
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 {
@@ -154,6 +179,18 @@ fun elements(): List<GenericFunction> {
}
}
templates add f("lastIndexOf(element: T)") {
only(Iterables, Sequences, ArraysOfObjects)
doc { "Returns last index of [element], or -1 if the collection does not contain element." }
returns("Int")
deprecate(Deprecation("Use 'indexOfRaw' instead.", "indexOfRaw(element)"))
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 {