Fixed some warnings in stdlib (#420)
This commit is contained in:
committed by
Nikolay Igotti
parent
bdd5ec83e1
commit
fb08c25633
@@ -33,10 +33,13 @@ public inline operator fun Char.plus(other: String) : String = this.toString() +
|
||||
* - Applying the method [toLowerCase] to each character produces the same result
|
||||
*/
|
||||
public fun Char.equals(other: Char, ignoreCase: Boolean = false): Boolean {
|
||||
@Suppress("DEPRECATED_IDENTITY_EQUALS")
|
||||
if (this === other) return true
|
||||
if (!ignoreCase) return false
|
||||
|
||||
@Suppress("DEPRECATED_IDENTITY_EQUALS")
|
||||
if (this.toUpperCase() === other.toUpperCase()) return true
|
||||
@Suppress("DEPRECATED_IDENTITY_EQUALS")
|
||||
if (this.toLowerCase() === other.toLowerCase()) return true
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import kotlinx.cinterop.NativePtr
|
||||
@Intrinsic external fun areEqualByValue(first: NativePointed?, second: NativePointed?): Boolean
|
||||
@Intrinsic external fun areEqualByValue(first: CPointer<*>?, second: CPointer<*>?): Boolean
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun areEqual(first: Any?, second: Any?): Boolean {
|
||||
return if (first == null) second == null else first.equals(second)
|
||||
}
|
||||
@@ -34,7 +34,7 @@ open class KProperty0Impl<out R>(override val name: String, val getter: () -> R)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
val otherKProperty = other as? KProperty0Impl<R>
|
||||
val otherKProperty = other as? KProperty0Impl<*>
|
||||
if (otherKProperty == null) return false
|
||||
return name == otherKProperty.name && getter == otherKProperty.getter
|
||||
}
|
||||
@@ -58,7 +58,7 @@ open class KProperty1Impl<T, out R>(override val name: String, val getter: (T) -
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
val otherKProperty = other as? KProperty1Impl<T, R>
|
||||
val otherKProperty = other as? KProperty1Impl<*, *>
|
||||
if (otherKProperty == null) return false
|
||||
return name == otherKProperty.name && getter == otherKProperty.getter
|
||||
}
|
||||
@@ -82,7 +82,7 @@ open class KProperty2Impl<T1, T2, out R>(override val name: String, val getter:
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
val otherKProperty = other as? KProperty2Impl<T1, T2, R>
|
||||
val otherKProperty = other as? KProperty2Impl<*, *, *>
|
||||
if (otherKProperty == null) return false
|
||||
return name == otherKProperty.name && getter == otherKProperty.getter
|
||||
}
|
||||
@@ -104,7 +104,7 @@ class KMutableProperty0Impl<R>(name: String, getter: () -> R, val setter: (R) ->
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
val otherKProperty = other as? KMutableProperty0Impl<R>
|
||||
val otherKProperty = other as? KMutableProperty0Impl<*>
|
||||
if (otherKProperty == null) return false
|
||||
return name == otherKProperty.name && getter == otherKProperty.getter && setter == otherKProperty.setter
|
||||
}
|
||||
@@ -126,7 +126,7 @@ class KMutableProperty1Impl<T, R>(name: String, getter: (T) -> R, val setter: (T
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
val otherKProperty = other as? KMutableProperty1Impl<T, R>
|
||||
val otherKProperty = other as? KMutableProperty1Impl<*, *>
|
||||
if (otherKProperty == null) return false
|
||||
return name == otherKProperty.name && getter == otherKProperty.getter && setter == otherKProperty.setter
|
||||
}
|
||||
@@ -148,7 +148,7 @@ class KMutableProperty2Impl<T1, T2, R>(name: String, getter: (T1, T2) -> R, val
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
val otherKProperty = other as? KMutableProperty2Impl<T1, T2, R>
|
||||
val otherKProperty = other as? KMutableProperty2Impl<* ,*, *>
|
||||
if (otherKProperty == null) return false
|
||||
return name == otherKProperty.name && getter == otherKProperty.getter && setter == otherKProperty.setter
|
||||
}
|
||||
|
||||
@@ -77,5 +77,6 @@ fun <T: Enum<T>> valuesForEnum(values: Array<T>): Array<T>
|
||||
val result = Array<T?>(values.size)
|
||||
for (value in values)
|
||||
result[value.ordinal] = value
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return result as Array<T>
|
||||
}
|
||||
@@ -169,6 +169,7 @@ external public fun String.toUpperCase(): String
|
||||
* Returns a copy of this string converted to lower case using the rules of the default locale.
|
||||
*/
|
||||
@SymbolName("Kotlin_String_toLowerCase")
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
external public inline fun String.toLowerCase(): String
|
||||
|
||||
/**
|
||||
|
||||
@@ -2583,56 +2583,67 @@ public inline fun <reified T> Collection<T>.toTypedArray(): Array<T> {
|
||||
val result = arrayOfNulls<T>(size)
|
||||
var index = 0
|
||||
for (element in this) result[index++] = element
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return result as Array<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the specified elements.
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
public inline fun <reified @PureReifiable T> arrayOf(vararg elements: T): Array<T> = elements as Array<T>
|
||||
|
||||
private val kEmptyArray = arrayOf<Any>()
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
public fun <T> emptyArray() = kEmptyArray as Array<T>
|
||||
|
||||
/**
|
||||
* Returns an array containing the specified [Double] numbers.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun doubleArrayOf(vararg elements: Double) = elements
|
||||
|
||||
/**
|
||||
* Returns an array containing the specified [Float] numbers.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun floatArrayOf(vararg elements: Float) = elements
|
||||
|
||||
/**
|
||||
* Returns an array containing the specified [Long] numbers.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun longArrayOf(vararg elements: Long) = elements
|
||||
|
||||
/**
|
||||
* Returns an array containing the specified [Int] numbers.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun intArrayOf(vararg elements: Int) = elements
|
||||
|
||||
/**
|
||||
* Returns an array containing the specified characters.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun charArrayOf(vararg elements: Char) = elements
|
||||
|
||||
/**
|
||||
* Returns an array containing the specified [Short] numbers.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun shortArrayOf(vararg elements: Short) = elements
|
||||
|
||||
/**
|
||||
* Returns an array containing the specified [Byte] numbers.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun byteArrayOf(vararg elements: Byte) = elements
|
||||
|
||||
/**
|
||||
* Returns an array containing the specified boolean values.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun booleanArrayOf(vararg elements: Boolean) = elements
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,7 @@ package kotlin
|
||||
* Throws an [AssertionError] if the [value] is false
|
||||
* and runtime assertions have been enabled during compilation.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun assert(value: Boolean) {
|
||||
assert(value) { "Assertion failed" }
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public abstract class Enum<E: Enum<E>>(public val name: String, public val ordin
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun <T: Enum<T>> enumValueOf(name: String): T {
|
||||
throw Exception("Call to this function should've been lowered")
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ public fun <T> lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> =
|
||||
* Also this behavior can be changed in the future.
|
||||
*/
|
||||
@FixmeConcurrency
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
public fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T> = TODO()//SynchronizedLazyImpl(initializer, lock)
|
||||
|
||||
/**
|
||||
|
||||
@@ -154,22 +154,22 @@ public final class Byte : Number(), Comparable<Byte> {
|
||||
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Byte_mod_Byte")
|
||||
external public operator fun mod(other: Byte): Int
|
||||
external public operator fun rem(other: Byte): Int
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Byte_mod_Short")
|
||||
external public operator fun mod(other: Short): Int
|
||||
external public operator fun rem(other: Short): Int
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Byte_mod_Int")
|
||||
external public operator fun mod(other: Int): Int
|
||||
external public operator fun rem(other: Int): Int
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Byte_mod_Long")
|
||||
external public operator fun mod(other: Long): Long
|
||||
external public operator fun rem(other: Long): Long
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Byte_mod_Float")
|
||||
external public operator fun mod(other: Float): Float
|
||||
external public operator fun rem(other: Float): Float
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Byte_mod_Double")
|
||||
external public operator fun mod(other: Double): Double
|
||||
external public operator fun rem(other: Double): Double
|
||||
|
||||
/** Increments this value. */
|
||||
@SymbolName("Kotlin_Byte_inc")
|
||||
@@ -381,22 +381,22 @@ public final class Short : Number(), Comparable<Short> {
|
||||
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Short_mod_Byte")
|
||||
external public operator fun mod(other: Byte): Int
|
||||
external public operator fun rem(other: Byte): Int
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Short_mod_Short")
|
||||
external public operator fun mod(other: Short): Int
|
||||
external public operator fun rem(other: Short): Int
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Short_mod_Int")
|
||||
external public operator fun mod(other: Int): Int
|
||||
external public operator fun rem(other: Int): Int
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Short_mod_Long")
|
||||
external public operator fun mod(other: Long): Long
|
||||
external public operator fun rem(other: Long): Long
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Short_mod_Float")
|
||||
external public operator fun mod(other: Float): Float
|
||||
external public operator fun rem(other: Float): Float
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Short_mod_Double")
|
||||
external public operator fun mod(other: Double): Double
|
||||
external public operator fun rem(other: Double): Double
|
||||
|
||||
/** Increments this value. */
|
||||
@SymbolName("Kotlin_Short_inc")
|
||||
@@ -608,22 +608,22 @@ public final class Int : Number(), Comparable<Int> {
|
||||
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Int_mod_Byte")
|
||||
external public operator fun mod(other: Byte): Int
|
||||
external public operator fun rem(other: Byte): Int
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Int_mod_Short")
|
||||
external public operator fun mod(other: Short): Int
|
||||
external public operator fun rem(other: Short): Int
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Int_mod_Int")
|
||||
external public operator fun mod(other: Int): Int
|
||||
external public operator fun rem(other: Int): Int
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Int_mod_Long")
|
||||
external public operator fun mod(other: Long): Long
|
||||
external public operator fun rem(other: Long): Long
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Int_mod_Float")
|
||||
external public operator fun mod(other: Float): Float
|
||||
external public operator fun rem(other: Float): Float
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Int_mod_Double")
|
||||
external public operator fun mod(other: Double): Double
|
||||
external public operator fun rem(other: Double): Double
|
||||
|
||||
/** Increments this value. */
|
||||
@SymbolName("Kotlin_Int_inc")
|
||||
@@ -704,33 +704,6 @@ public final class Int : Number(), Comparable<Int> {
|
||||
public override fun hashCode(): Int {
|
||||
return this
|
||||
}
|
||||
|
||||
// TODO: make extensions.
|
||||
fun highestOneBit() : Int {
|
||||
var index = 31
|
||||
|
||||
while (index >= 0) {
|
||||
var mask = (1 shl index)
|
||||
if ((mask and this) != 0) {
|
||||
return mask
|
||||
}
|
||||
index--
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
fun numberOfLeadingZeros() : Int {
|
||||
var index = 31
|
||||
|
||||
while (index >= 0) {
|
||||
var mask = (1 shl index)
|
||||
if ((mask and this) != 0) {
|
||||
return 31 - index
|
||||
}
|
||||
index--
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -871,22 +844,22 @@ public final class Long : Number(), Comparable<Long> {
|
||||
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Long_mod_Byte")
|
||||
external public operator fun mod(other: Byte): Long
|
||||
external public operator fun rem(other: Byte): Long
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Long_mod_Short")
|
||||
external public operator fun mod(other: Short): Long
|
||||
external public operator fun rem(other: Short): Long
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Long_mod_Int")
|
||||
external public operator fun mod(other: Int): Long
|
||||
external public operator fun rem(other: Int): Long
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Long_mod_Long")
|
||||
external public operator fun mod(other: Long): Long
|
||||
external public operator fun rem(other: Long): Long
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Long_mod_Float")
|
||||
external public operator fun mod(other: Float): Float
|
||||
external public operator fun rem(other: Float): Float
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Long_mod_Double")
|
||||
external public operator fun mod(other: Double): Double
|
||||
external public operator fun rem(other: Double): Double
|
||||
|
||||
/** Increments this value. */
|
||||
@SymbolName("Kotlin_Long_inc")
|
||||
@@ -988,16 +961,19 @@ public final class Float : Number(), Comparable<Float> {
|
||||
/**
|
||||
* A constant holding the positive infinity value of Float.
|
||||
*/
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public val POSITIVE_INFINITY: Float = 1.0f / 0.0f
|
||||
|
||||
/**
|
||||
* A constant holding the negative infinity value of Float.
|
||||
*/
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public val NEGATIVE_INFINITY: Float = -1.0f / 0.0f
|
||||
|
||||
/**
|
||||
* A constant holding the "not a number" value of Float.
|
||||
*/
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public val NaN: Float = 0.0f / 0.0f
|
||||
}
|
||||
|
||||
@@ -1122,22 +1098,22 @@ public final class Float : Number(), Comparable<Float> {
|
||||
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Float_mod_Byte")
|
||||
external public operator fun mod(other: Byte): Float
|
||||
external public operator fun rem(other: Byte): Float
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Float_mod_Short")
|
||||
external public operator fun mod(other: Short): Float
|
||||
external public operator fun rem(other: Short): Float
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Float_mod_Int")
|
||||
external public operator fun mod(other: Int): Float
|
||||
external public operator fun rem(other: Int): Float
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Float_mod_Long")
|
||||
external public operator fun mod(other: Long): Float
|
||||
external public operator fun rem(other: Long): Float
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Float_mod_Float")
|
||||
external public operator fun mod(other: Float): Float
|
||||
external public operator fun rem(other: Float): Float
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Float_mod_Double")
|
||||
external public operator fun mod(other: Double): Double
|
||||
external public operator fun rem(other: Double): Double
|
||||
|
||||
/** Increments this value. */
|
||||
@SymbolName("Kotlin_Float_inc")
|
||||
@@ -1205,16 +1181,19 @@ public final class Double : Number(), Comparable<Double> {
|
||||
/**
|
||||
* A constant holding the positive infinity value of Double.
|
||||
*/
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public val POSITIVE_INFINITY: Double = 1.0 / 0.0
|
||||
|
||||
/**
|
||||
* A constant holding the negative infinity value of Double.
|
||||
*/
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public val NEGATIVE_INFINITY: Double = -1.0 / 0.0
|
||||
|
||||
/**
|
||||
* A constant holding the "not a number" value of Double.
|
||||
*/
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public val NaN: Double = 0.0 / 0.0
|
||||
}
|
||||
|
||||
@@ -1339,22 +1318,22 @@ public final class Double : Number(), Comparable<Double> {
|
||||
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Double_mod_Byte")
|
||||
external public operator fun mod(other: Byte): Double
|
||||
external public operator fun rem(other: Byte): Double
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Double_mod_Short")
|
||||
external public operator fun mod(other: Short): Double
|
||||
external public operator fun rem(other: Short): Double
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Double_mod_Int")
|
||||
external public operator fun mod(other: Int): Double
|
||||
external public operator fun rem(other: Int): Double
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Double_mod_Long")
|
||||
external public operator fun mod(other: Long): Double
|
||||
external public operator fun rem(other: Long): Double
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Double_mod_Float")
|
||||
external public operator fun mod(other: Float): Double
|
||||
external public operator fun rem(other: Float): Double
|
||||
/** Calculates the remainder of dividing this value by the other value. */
|
||||
@SymbolName("Kotlin_Double_mod_Double")
|
||||
external public operator fun mod(other: Double): Double
|
||||
external public operator fun rem(other: Double): Double
|
||||
|
||||
/** Increments this value. */
|
||||
@SymbolName("Kotlin_Double_inc")
|
||||
|
||||
@@ -42,6 +42,7 @@ public open class Throwable(open val message: String?, open val cause: Throwable
|
||||
this.cause?.printEnclosedStackTrace(this)
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
private fun printEnclosedStackTrace(enclosing: Throwable) {
|
||||
// TODO: should skip common stack frames
|
||||
print("Caused by: ")
|
||||
|
||||
@@ -128,6 +128,7 @@ public inline fun <T> List<T>?.orEmpty(): List<T> = this ?: emptyList()
|
||||
* Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection<E>`.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
public inline fun <@kotlin.internal.OnlyInputTypes T> Collection<T>.containsAll(
|
||||
elements: Collection<T>): Boolean = this.containsAll(elements)
|
||||
|
||||
@@ -555,6 +556,7 @@ public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.indexOf(element: T):
|
||||
/**
|
||||
* Returns first index of [element], or -1 if the list does not contain element.
|
||||
*/
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
public fun <@kotlin.internal.OnlyInputTypes T> List<T>.indexOf(element: T): Int {
|
||||
return indexOf(element)
|
||||
}
|
||||
@@ -674,6 +676,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.
|
||||
*/
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.lastIndexOf(element: T): Int {
|
||||
if (this is List) return this.lastIndexOf(element)
|
||||
var lastIndex = -1
|
||||
@@ -689,6 +692,7 @@ public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.lastIndexOf(element:
|
||||
/**
|
||||
* Returns last index of [element], or -1 if the list does not contain element.
|
||||
*/
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
public fun <@kotlin.internal.OnlyInputTypes T> List<T>.lastIndexOf(element: T): Int {
|
||||
return lastIndexOf(element)
|
||||
}
|
||||
@@ -2192,6 +2196,7 @@ public infix fun <T, R> Iterable<T>.zip(other: Array<out R>): List<Pair<T, R>> {
|
||||
return zip(other) { t1, t2 -> t1 to t2 }
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun min(x1: Int, x2: Int) = if (x1 < x2) x1 else x2
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@ private object EmptyMap : Map<Any?, Nothing> {
|
||||
* Returns an empty read-only map of specified type. The returned map is serializable (JVM).
|
||||
* @sample samples.collections.Maps.Instantiation.emptyReadOnlyMap
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
public fun <K, V> emptyMap(): Map<K, V> = EmptyMap as Map<K, V>
|
||||
|
||||
/**
|
||||
@@ -162,6 +163,7 @@ public inline fun <@kotlin.internal.OnlyInputTypes K> Map<out K, *>.containsKey(
|
||||
* Allows to overcome type-safety restriction of `containsValue` that requires to pass a value of type `V`.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
public inline fun <K, @kotlin.internal.OnlyInputTypes V> Map<K, V>.containsValue(value: V): Boolean = this.containsValue(value)
|
||||
|
||||
|
||||
|
||||
@@ -952,6 +952,7 @@ public inline fun <reified R> Sequence<*>.filterIsInstance(): Sequence<@kotlin.i
|
||||
* Appends all elements that are instances of specified type parameter R to the given [destination].
|
||||
*/
|
||||
@FixmeReified
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
public inline fun <reified R, C : MutableCollection<in R>> Sequence<*>.filterIsInstanceTo(destination: C): C {
|
||||
//for (element in this) if (element is R) destination.add(element)
|
||||
//return destination
|
||||
|
||||
@@ -52,7 +52,7 @@ public fun StringBuilder.append(vararg value: Any?): StringBuilder {
|
||||
internal fun <T> Appendable.appendElement(element: T, transform: ((T) -> CharSequence)?) {
|
||||
when {
|
||||
transform != null -> append(transform(element))
|
||||
element is CharSequence? -> append(element)
|
||||
element is CharSequence -> append(element)
|
||||
element is Char -> append(element)
|
||||
else -> append(element.toString())
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ external public fun Char.isIdentifierIgnorable(): Boolean
|
||||
* Returns `true` if this character is an ISO control character.
|
||||
*/
|
||||
@SymbolName("Kotlin_Char_isISOControl")
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
external public inline fun Char.isISOControl(): Boolean
|
||||
|
||||
/**
|
||||
|
||||
@@ -304,6 +304,7 @@ public fun CharSequence.subSequence(range: IntRange): CharSequence = subSequence
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
@Deprecated("Use parameters named startIndex and endIndex.", ReplaceWith("subSequence(startIndex = start, endIndex = end)"))
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
public inline fun String.subSequence(start: Int, end: Int): CharSequence = subSequence(start, end)
|
||||
|
||||
/**
|
||||
@@ -714,7 +715,7 @@ public fun CharSequence.endsWith(char: Char, ignoreCase: Boolean = false): Boole
|
||||
*/
|
||||
public fun CharSequence.startsWith(prefix: CharSequence, ignoreCase: Boolean = false): Boolean {
|
||||
if (!ignoreCase && this is String && prefix is String)
|
||||
return (this as String).startsWith(prefix)
|
||||
return this.startsWith(prefix)
|
||||
else
|
||||
return regionMatchesImpl(0, prefix, 0, prefix.length, ignoreCase)
|
||||
}
|
||||
@@ -724,7 +725,7 @@ public fun CharSequence.startsWith(prefix: CharSequence, ignoreCase: Boolean = f
|
||||
*/
|
||||
public fun CharSequence.startsWith(prefix: CharSequence, startIndex: Int, ignoreCase: Boolean = false): Boolean {
|
||||
if (!ignoreCase && this is String && prefix is String)
|
||||
return (this as String).startsWith(prefix, startIndex)
|
||||
return this.startsWith(prefix, startIndex)
|
||||
else
|
||||
return regionMatchesImpl(startIndex, prefix, 0, prefix.length, ignoreCase)
|
||||
}
|
||||
@@ -734,7 +735,7 @@ public fun CharSequence.startsWith(prefix: CharSequence, startIndex: Int, ignore
|
||||
*/
|
||||
public fun CharSequence.endsWith(suffix: CharSequence, ignoreCase: Boolean = false): Boolean {
|
||||
if (!ignoreCase && this is String && suffix is String)
|
||||
return (this as String).endsWith(suffix)
|
||||
return this.endsWith(suffix)
|
||||
else
|
||||
return regionMatchesImpl(length - suffix.length, suffix, 0, suffix.length, ignoreCase)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import kotlin.comparisons.*
|
||||
private fun <T> partition(array: Array<T>, left: Int, right: Int): Int {
|
||||
var i = left
|
||||
var j = right
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val pivot = array[(left + right) / 2] as Comparable<T>
|
||||
while (i <= j) {
|
||||
while (pivot.compareTo(array[i]) > 0) {
|
||||
@@ -81,9 +82,11 @@ private fun <T> quickSort(
|
||||
|
||||
internal fun <T> sortArrayWith(
|
||||
array: Array<out T>, fromIndex: Int, toIndex: Int, comparator: Comparator<T>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
quickSort(array as Array<T>, fromIndex, toIndex, comparator)
|
||||
}
|
||||
|
||||
internal fun <T> sortArrayComparable(array: Array<out T>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
quickSort(array as Array<T>, 0, array.size - 1)
|
||||
}
|
||||
Reference in New Issue
Block a user