Cleanup: suppress warnings where appropriate.
This commit is contained in:
@@ -10823,6 +10823,7 @@ public fun <T : Any> Array<T?>.requireNoNulls(): Array<T> {
|
||||
throw IllegalArgumentException("null element found in $this.")
|
||||
}
|
||||
}
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
return this as Array<T>
|
||||
}
|
||||
|
||||
@@ -12531,6 +12532,7 @@ public inline fun <reified R, C : MutableCollection<in R>> Array<*>.filterIsInst
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public fun <C : MutableCollection<in R>, R> Array<*>.filterIsInstanceTo(destination: C, klass: Class<R>): C {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
for (element in this) if (klass.isInstance(element)) destination.add(element as R)
|
||||
return destination
|
||||
}
|
||||
@@ -13002,6 +13004,7 @@ public fun ByteArray.toTypedArray(): Array<Byte> {
|
||||
val result = arrayOfNulls<Byte>(size)
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
return result as Array<Byte>
|
||||
}
|
||||
|
||||
@@ -13013,6 +13016,7 @@ public fun ShortArray.toTypedArray(): Array<Short> {
|
||||
val result = arrayOfNulls<Short>(size)
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
return result as Array<Short>
|
||||
}
|
||||
|
||||
@@ -13024,6 +13028,7 @@ public fun IntArray.toTypedArray(): Array<Int> {
|
||||
val result = arrayOfNulls<Int>(size)
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
return result as Array<Int>
|
||||
}
|
||||
|
||||
@@ -13035,6 +13040,7 @@ public fun LongArray.toTypedArray(): Array<Long> {
|
||||
val result = arrayOfNulls<Long>(size)
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
return result as Array<Long>
|
||||
}
|
||||
|
||||
@@ -13046,6 +13052,7 @@ public fun FloatArray.toTypedArray(): Array<Float> {
|
||||
val result = arrayOfNulls<Float>(size)
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
return result as Array<Float>
|
||||
}
|
||||
|
||||
@@ -13057,6 +13064,7 @@ public fun DoubleArray.toTypedArray(): Array<Double> {
|
||||
val result = arrayOfNulls<Double>(size)
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
return result as Array<Double>
|
||||
}
|
||||
|
||||
@@ -13068,6 +13076,7 @@ public fun BooleanArray.toTypedArray(): Array<Boolean> {
|
||||
val result = arrayOfNulls<Boolean>(size)
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
return result as Array<Boolean>
|
||||
}
|
||||
|
||||
@@ -13079,6 +13088,7 @@ public fun CharArray.toTypedArray(): Array<Char> {
|
||||
val result = arrayOfNulls<Char>(size)
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
return result as Array<Char>
|
||||
}
|
||||
|
||||
|
||||
@@ -799,6 +799,7 @@ public fun <T : Comparable<T>> MutableList<T>.sortDescending(): Unit {
|
||||
public fun <T : Comparable<T>> Iterable<T>.sorted(): List<T> {
|
||||
if (this is Collection) {
|
||||
if (size <= 1) return this.toMutableList()
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
return (toTypedArray<Comparable<T>>() as Array<T>).apply { sort() }.asList()
|
||||
}
|
||||
return toMutableList().apply { sort() }
|
||||
@@ -831,6 +832,7 @@ public fun <T : Comparable<T>> Iterable<T>.sortedDescending(): List<T> {
|
||||
public fun <T> Iterable<T>.sortedWith(comparator: Comparator<in T>): List<T> {
|
||||
if (this is Collection) {
|
||||
if (size <= 1) return this.toMutableList()
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
return (toTypedArray<Any?>() as Array<T>).apply { sortWith(comparator) }.asList()
|
||||
}
|
||||
return toMutableList().apply { sortWith(comparator) }
|
||||
@@ -1593,6 +1595,7 @@ public fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> {
|
||||
throw IllegalArgumentException("null element found in $this.")
|
||||
}
|
||||
}
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return this as Iterable<T>
|
||||
}
|
||||
|
||||
@@ -1605,6 +1608,7 @@ public fun <T : Any> List<T?>.requireNoNulls(): List<T> {
|
||||
throw IllegalArgumentException("null element found in $this.")
|
||||
}
|
||||
}
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return this as List<T>
|
||||
}
|
||||
|
||||
@@ -1896,6 +1900,7 @@ public inline fun <reified R, C : MutableCollection<in R>> Iterable<*>.filterIsI
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(destination: C, klass: Class<R>): C {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
for (element in this) if (klass.isInstance(element)) destination.add(element as R)
|
||||
return destination
|
||||
}
|
||||
|
||||
@@ -343,6 +343,7 @@ public fun <T> Sequence<T>.filterNot(predicate: (T) -> Boolean): Sequence<T> {
|
||||
* Returns a sequence containing all elements that are not `null`.
|
||||
*/
|
||||
public fun <T : Any> Sequence<T?>.filterNotNull(): Sequence<T> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return filterNot { it == null } as Sequence<T>
|
||||
}
|
||||
|
||||
@@ -1179,6 +1180,7 @@ public inline fun <T> Sequence<T>.asSequence(): Sequence<T> {
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public inline fun <reified R> Sequence<*>.filterIsInstance(): Sequence<@kotlin.internal.NoInfer R> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return filter { it is R } as Sequence<R>
|
||||
}
|
||||
|
||||
@@ -1187,6 +1189,7 @@ public inline fun <reified R> Sequence<*>.filterIsInstance(): Sequence<@kotlin.i
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public fun <R> Sequence<*>.filterIsInstance(klass: Class<R>): Sequence<R> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return filter { klass.isInstance(it) } as Sequence<R>
|
||||
}
|
||||
|
||||
@@ -1204,6 +1207,7 @@ public inline fun <reified R, C : MutableCollection<in R>> Sequence<*>.filterIsI
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public fun <C : MutableCollection<in R>, R> Sequence<*>.filterIsInstanceTo(destination: C, klass: Class<R>): C {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
for (element in this) if (klass.isInstance(element)) destination.add(element as R)
|
||||
return destination
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user