Suppress UNCHECKED_CAST instead of CAST_NEVER_SUCCEEDS in several places
This is related to KT-6611 being fixed recently. Note that not all cases of incorrect "cast never succeeds" were fixed
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("unused", "UNCHECKED_CAST", "CAST_NEVER_SUCCEEDS")
|
@file:Suppress("unused", "UNCHECKED_CAST")
|
||||||
|
|
||||||
package org.jetbrains.kotlin.codegen.intrinsics
|
package org.jetbrains.kotlin.codegen.intrinsics
|
||||||
|
|
||||||
|
|||||||
-2
@@ -256,11 +256,9 @@ class OverloadingConflictResolver(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// Different smartcasts may lead to the same candidate descriptor wrapped into different ResolvedCallImpl objects
|
// Different smartcasts may lead to the same candidate descriptor wrapped into different ResolvedCallImpl objects
|
||||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
|
||||||
private fun <D : CallableDescriptor> uniquifyCandidatesSet(candidates: Collection<MutableResolvedCall<D>>): Set<MutableResolvedCall<D>> =
|
private fun <D : CallableDescriptor> uniquifyCandidatesSet(candidates: Collection<MutableResolvedCall<D>>): Set<MutableResolvedCall<D>> =
|
||||||
THashSet<MutableResolvedCall<D>>(candidates.size, getCallHashingStrategy<MutableResolvedCall<D>>()).apply { addAll(candidates) }
|
THashSet<MutableResolvedCall<D>>(candidates.size, getCallHashingStrategy<MutableResolvedCall<D>>()).apply { addAll(candidates) }
|
||||||
|
|
||||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
|
||||||
private fun <C> newResolvedCallSet(expectedSize: Int): MutableSet<C> =
|
private fun <C> newResolvedCallSet(expectedSize: Int): MutableSet<C> =
|
||||||
THashSet<C>(expectedSize, getCallHashingStrategy<C>())
|
THashSet<C>(expectedSize, getCallHashingStrategy<C>())
|
||||||
|
|
||||||
|
|||||||
@@ -22,5 +22,5 @@ import kotlin.internal.PureReifiable
|
|||||||
* Returns an empty array of the specified type [T].
|
* Returns an empty array of the specified type [T].
|
||||||
*/
|
*/
|
||||||
public inline fun <reified @PureReifiable T> emptyArray(): Array<T> =
|
public inline fun <reified @PureReifiable T> emptyArray(): Array<T> =
|
||||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
@Suppress("UNCHECKED_CAST")
|
||||||
arrayOfNulls<T>(0) as Array<T>
|
(arrayOfNulls<T>(0) as Array<T>)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ abstract class PrimitiveSpreadBuilder<T : Any>(private val size: Int) {
|
|||||||
|
|
||||||
protected var position: Int = 0
|
protected var position: Int = 0
|
||||||
|
|
||||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
@Suppress("UNCHECKED_CAST")
|
||||||
private val spreads: Array<T?> = arrayOfNulls<Any>(size) as Array<T?>
|
private val spreads: Array<T?> = arrayOfNulls<Any>(size) as Array<T?>
|
||||||
|
|
||||||
fun addSpread(spreadArgument: T) {
|
fun addSpread(spreadArgument: T) {
|
||||||
|
|||||||
@@ -10973,7 +10973,7 @@ public fun <T : Any> Array<T?>.requireNoNulls(): Array<T> {
|
|||||||
throw IllegalArgumentException("null element found in $this.")
|
throw IllegalArgumentException("null element found in $this.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return this as Array<T>
|
return this as Array<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -827,7 +827,7 @@ public fun <T : Comparable<T>> MutableList<T>.sortDescending(): Unit {
|
|||||||
public fun <T : Comparable<T>> Iterable<T>.sorted(): List<T> {
|
public fun <T : Comparable<T>> Iterable<T>.sorted(): List<T> {
|
||||||
if (this is Collection) {
|
if (this is Collection) {
|
||||||
if (size <= 1) return this.toList()
|
if (size <= 1) return this.toList()
|
||||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return (toTypedArray<Comparable<T>>() as Array<T>).apply { sort() }.asList()
|
return (toTypedArray<Comparable<T>>() as Array<T>).apply { sort() }.asList()
|
||||||
}
|
}
|
||||||
return toMutableList().apply { sort() }
|
return toMutableList().apply { sort() }
|
||||||
@@ -860,7 +860,7 @@ public fun <T : Comparable<T>> Iterable<T>.sortedDescending(): List<T> {
|
|||||||
public fun <T> Iterable<T>.sortedWith(comparator: Comparator<in T>): List<T> {
|
public fun <T> Iterable<T>.sortedWith(comparator: Comparator<in T>): List<T> {
|
||||||
if (this is Collection) {
|
if (this is Collection) {
|
||||||
if (size <= 1) return this.toList()
|
if (size <= 1) return this.toList()
|
||||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return (toTypedArray<Any?>() as Array<T>).apply { sortWith(comparator) }.asList()
|
return (toTypedArray<Any?>() as Array<T>).apply { sortWith(comparator) }.asList()
|
||||||
}
|
}
|
||||||
return toMutableList().apply { sortWith(comparator) }
|
return toMutableList().apply { sortWith(comparator) }
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ internal fun <T> List<T>.optimizeReadOnlyList() = when (size) {
|
|||||||
private fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<Any?> =
|
private fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<Any?> =
|
||||||
if (isVarargs && this.javaClass == Array<Any?>::class.java)
|
if (isVarargs && this.javaClass == Array<Any?>::class.java)
|
||||||
// if the array came from varargs and already is array of Any, copying isn't required
|
// if the array came from varargs and already is array of Any, copying isn't required
|
||||||
@Suppress("CAST_NEVER_SUCCEEDS") (this as Array<Any?>)
|
@Suppress("UNCHECKED_CAST") (this as Array<Any?>)
|
||||||
else
|
else
|
||||||
Arrays.copyOf(this, this.size, Array<Any?>::class.java)
|
Arrays.copyOf(this, this.size, Array<Any?>::class.java)
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ fun filtering(): List<GenericFunction> {
|
|||||||
val list = ArrayList<T>(n)
|
val list = ArrayList<T>(n)
|
||||||
for (item in this) {
|
for (item in this) {
|
||||||
if (count++ == n)
|
if (count++ == n)
|
||||||
break;
|
break
|
||||||
list.add(item)
|
list.add(item)
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
@@ -292,7 +292,7 @@ fun filtering(): List<GenericFunction> {
|
|||||||
val list = ArrayList<T>()
|
val list = ArrayList<T>()
|
||||||
for (item in this) {
|
for (item in this) {
|
||||||
if (!predicate(item))
|
if (!predicate(item))
|
||||||
break;
|
break
|
||||||
list.add(item)
|
list.add(item)
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ fun guards(): List<GenericFunction> {
|
|||||||
typeParam("T : Any")
|
typeParam("T : Any")
|
||||||
toNullableT = true
|
toNullableT = true
|
||||||
returns("SELF")
|
returns("SELF")
|
||||||
body { f ->
|
body {
|
||||||
"""
|
"""
|
||||||
for (element in this) {
|
for (element in this) {
|
||||||
if (element == null) {
|
if (element == null) {
|
||||||
throw IllegalArgumentException("null element found in $THIS.")
|
throw IllegalArgumentException("null element found in $THIS.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Suppress("${if (f == InvariantArraysOfObjects) "CAST_NEVER_SUCCEEDS" else "UNCHECKED_CAST"}")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return this as SELF
|
return this as SELF
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ fun ordering(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
if (this is Collection) {
|
if (this is Collection) {
|
||||||
if (size <= 1) return this.toList()
|
if (size <= 1) return this.toList()
|
||||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return (toTypedArray<Comparable<T>>() as Array<T>).apply { sort() }.asList()
|
return (toTypedArray<Comparable<T>>() as Array<T>).apply { sort() }.asList()
|
||||||
}
|
}
|
||||||
return toMutableList().apply { sort() }
|
return toMutableList().apply { sort() }
|
||||||
@@ -232,7 +232,7 @@ fun ordering(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
if (this is Collection) {
|
if (this is Collection) {
|
||||||
if (size <= 1) return this.toList()
|
if (size <= 1) return this.toList()
|
||||||
@Suppress("CAST_NEVER_SUCCEEDS")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return (toTypedArray<Any?>() as Array<T>).apply { sortWith(comparator) }.asList()
|
return (toTypedArray<Any?>() as Array<T>).apply { sortWith(comparator) }.asList()
|
||||||
}
|
}
|
||||||
return toMutableList().apply { sortWith(comparator) }
|
return toMutableList().apply { sortWith(comparator) }
|
||||||
|
|||||||
Reference in New Issue
Block a user