Generate contains, indexOf, lastIndexOf with @NoInfer

This commit is contained in:
Ilya Gorbunov
2015-10-13 22:59:03 +03:00
parent 69a924a3ab
commit 95aac7ade6
4 changed files with 19 additions and 16 deletions
@@ -55,7 +55,7 @@ public inline operator fun <T> List<T>.component5(): T {
/**
* Returns `true` if [element] is found in the collection.
*/
public operator fun <T> Iterable<T>.contains(element: T): Boolean {
public operator fun <T> Iterable<T>.contains(element: @kotlin.internal.NoInfer T): Boolean {
if (this is Collection)
return contains(element)
return indexOf(element) >= 0
@@ -249,7 +249,7 @@ public fun <T> List<T>.getOrNull(index: Int): T? {
/**
* Returns first index of [element], or -1 if the collection does not contain element.
*/
public fun <T> Iterable<T>.indexOf(element: T): Int {
public fun <T> Iterable<T>.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 <T> List<T>.last(predicate: (T) -> Boolean): T {
/**
* Returns last index of [element], or -1 if the collection does not contain element.
*/
public fun <T> Iterable<T>.lastIndexOf(element: T): Int {
public fun <T> Iterable<T>.lastIndexOf(element: @kotlin.internal.NoInfer T): Int {
if (this is List) return this.lastIndexOf(element)
var lastIndex = -1
var index = 0