Fixed some warnings in stdlib (#420)

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