diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 0e2c71039ae..6eee501e14e 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -375,7 +375,7 @@ public inline operator fun ShortArray.component5(): Short { /** * Returns `true` if [element] is found in the collection. */ -public operator fun Array.contains(element: T): Boolean { +public operator fun Array.contains(element: @kotlin.internal.NoInfer T): Boolean { return indexOf(element) >= 0 } @@ -1194,7 +1194,7 @@ public fun ShortArray.getOrNull(index: Int): Short? { /** * Returns first index of [element], or -1 if the collection does not contain element. */ -public fun Array.indexOf(element: T): Int { +public fun Array.indexOf(element: @kotlin.internal.NoInfer T): Int { if (element == null) { for (index in indices) { if (this[index] == null) { @@ -1733,7 +1733,7 @@ public inline fun ShortArray.last(predicate: (Short) -> Boolean): Short { /** * Returns last index of [element], or -1 if the collection does not contain element. */ -public fun Array.lastIndexOf(element: T): Int { +public fun Array.lastIndexOf(element: @kotlin.internal.NoInfer T): Int { if (element == null) { for (index in indices.reversed()) { if (this[index] == null) { diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index ed1a082b0b0..6a4ce7ab0d2 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -55,7 +55,7 @@ public inline operator fun List.component5(): T { /** * Returns `true` if [element] is found in the collection. */ -public operator fun Iterable.contains(element: T): Boolean { +public operator fun Iterable.contains(element: @kotlin.internal.NoInfer T): Boolean { if (this is Collection) return contains(element) return indexOf(element) >= 0 @@ -249,7 +249,7 @@ public fun List.getOrNull(index: Int): T? { /** * Returns first index of [element], or -1 if the collection does not contain element. */ -public fun Iterable.indexOf(element: T): Int { +public fun Iterable.indexOf(element: @kotlin.internal.NoInfer T): Int { if (this is List) return this.indexOf(element) var index = 0 for (item in this) { @@ -397,7 +397,7 @@ public inline fun List.last(predicate: (T) -> Boolean): T { /** * Returns last index of [element], or -1 if the collection does not contain element. */ -public fun Iterable.lastIndexOf(element: T): Int { +public fun Iterable.lastIndexOf(element: @kotlin.internal.NoInfer T): Int { if (this is List) return this.lastIndexOf(element) var lastIndex = -1 var index = 0 diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index bdc88df2c83..6bf5e875ff9 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -15,7 +15,7 @@ import java.util.Collections // TODO: it's temporary while we have java.util.Col /** * Returns `true` if [element] is found in the collection. */ -public operator fun Sequence.contains(element: T): Boolean { +public operator fun Sequence.contains(element: @kotlin.internal.NoInfer T): Boolean { return indexOf(element) >= 0 } @@ -122,7 +122,7 @@ public inline fun Sequence.firstOrNull(predicate: (T) -> Boolean): T? { /** * Returns first index of [element], or -1 if the collection does not contain element. */ -public fun Sequence.indexOf(element: T): Int { +public fun Sequence.indexOf(element: @kotlin.internal.NoInfer T): Int { var index = 0 for (item in this) { if (element == item) @@ -202,7 +202,7 @@ public inline fun Sequence.last(predicate: (T) -> Boolean): T { /** * Returns last index of [element], or -1 if the collection does not contain element. */ -public fun Sequence.lastIndexOf(element: T): Int { +public fun Sequence.lastIndexOf(element: @kotlin.internal.NoInfer T): Int { var lastIndex = -1 var index = 0 for (item in this) { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt index 48f2a4d01e8..f3ef40d7b5e 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt @@ -8,16 +8,17 @@ fun elements(): List { 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 { } 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 { } 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 -> """