Cleanup: suppress warnings where appropriate.
This commit is contained in:
@@ -529,6 +529,7 @@ fun filtering(): List<GenericFunction> {
|
||||
returns(Sequences) { "Sequence<T>" }
|
||||
body(Sequences) {
|
||||
"""
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return filterNot { it == null } as Sequence<T>
|
||||
"""
|
||||
}
|
||||
|
||||
@@ -13,13 +13,14 @@ fun guards(): List<GenericFunction> {
|
||||
typeParam("T : Any")
|
||||
toNullableT = true
|
||||
returns("SELF")
|
||||
body {
|
||||
body { f ->
|
||||
"""
|
||||
for (element in this) {
|
||||
if (element == null) {
|
||||
throw IllegalArgumentException("null element found in $THIS.")
|
||||
}
|
||||
}
|
||||
@Suppress("${if (f == InvariantArraysOfObjects) "CAST_NEVER_SUCCEEDS" else "UNCHECKED_CAST"}")
|
||||
return this as SELF
|
||||
"""
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ fun ordering(): List<GenericFunction> {
|
||||
"""
|
||||
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() }
|
||||
@@ -231,6 +232,7 @@ fun ordering(): List<GenericFunction> {
|
||||
"""
|
||||
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) }
|
||||
|
||||
@@ -202,6 +202,7 @@ fun specialJVM(): List<GenericFunction> {
|
||||
exclude(ArraysOfPrimitives, Strings)
|
||||
body {
|
||||
"""
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
for (element in this) if (klass.isInstance(element)) destination.add(element as R)
|
||||
return destination
|
||||
"""
|
||||
@@ -224,6 +225,7 @@ fun specialJVM(): List<GenericFunction> {
|
||||
returns(Sequences) { "Sequence<R>" }
|
||||
body(Sequences) {
|
||||
"""
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return filter { klass.isInstance(it) } as Sequence<R>
|
||||
"""
|
||||
}
|
||||
@@ -264,6 +266,7 @@ fun specialJVM(): List<GenericFunction> {
|
||||
receiverAsterisk(true)
|
||||
body(Sequences) {
|
||||
"""
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return filter { it is R } as Sequence<R>
|
||||
"""
|
||||
}
|
||||
@@ -307,6 +310,7 @@ fun specialJVM(): List<GenericFunction> {
|
||||
val result = arrayOfNulls<T>(size)
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
||||
return result as Array<T>
|
||||
"""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user