Generate contains, indexOf, lastIndexOf with @NoInfer
This commit is contained in:
@@ -8,16 +8,17 @@ fun elements(): List<GenericFunction> {
|
||||
templates add f("contains(element: T)") {
|
||||
operator(true)
|
||||
|
||||
only(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives)
|
||||
doc { "Returns `true` if [element] is found in the collection." }
|
||||
customSignature(Iterables, ArraysOfObjects, Sequences) { "contains(element: @kotlin.internal.NoInfer T)" }
|
||||
returns("Boolean")
|
||||
body {
|
||||
body(Iterables) {
|
||||
"""
|
||||
if (this is Collection)
|
||||
return contains(element)
|
||||
return indexOf(element) >= 0
|
||||
if (this is Collection)
|
||||
return contains(element)
|
||||
return indexOf(element) >= 0
|
||||
"""
|
||||
}
|
||||
exclude(Strings, Lists, Collections)
|
||||
body(ArraysOfPrimitives, ArraysOfObjects, Sequences) {
|
||||
"""
|
||||
return indexOf(element) >= 0
|
||||
@@ -41,8 +42,9 @@ fun elements(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("indexOf(element: T)") {
|
||||
exclude(Strings, Lists) // has native implementation
|
||||
only(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives)
|
||||
doc { "Returns first index of [element], or -1 if the collection does not contain element." }
|
||||
customSignature(Iterables, ArraysOfObjects, Sequences) { "indexOf(element: @kotlin.internal.NoInfer T)" }
|
||||
returns("Int")
|
||||
body { f ->
|
||||
"""
|
||||
@@ -104,8 +106,9 @@ fun elements(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("lastIndexOf(element: T)") {
|
||||
exclude(Strings, Lists) // has native implementation
|
||||
only(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives)
|
||||
doc { "Returns last index of [element], or -1 if the collection does not contain element." }
|
||||
customSignature(Iterables, ArraysOfObjects, Sequences) { "lastIndexOf(element: @kotlin.internal.NoInfer T)" }
|
||||
returns("Int")
|
||||
body { f ->
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user