Suppress code warnings in kotlin-stdlib
This commit is contained in:
@@ -328,7 +328,7 @@ public interface Map<K, out V> {
|
||||
@PlatformDependent
|
||||
public fun getOrDefault(key: K, defaultValue: @UnsafeVariance V): V {
|
||||
// See default implementation in JDK sources
|
||||
return null as V
|
||||
throw NotImplementedError()
|
||||
}
|
||||
|
||||
// Views
|
||||
|
||||
@@ -138,6 +138,7 @@ public expect fun Throwable.stackTraceToString(): String
|
||||
* Prints the [detailed description][Throwable.stackTraceToString] of this throwable to the standard output or standard error output.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
public expect fun Throwable.printStackTrace(): Unit
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("NON_ABSTRACT_FUNCTION_WITH_NO_BODY")
|
||||
@file:Suppress("NON_ABSTRACT_FUNCTION_WITH_NO_BODY", "UNUSED_PARAMETER")
|
||||
|
||||
package kotlin
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ public class Char internal constructor(private val value: Int) : Comparable<Char
|
||||
public fun toDouble(): Double = value.toDouble()
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
@Suppress("IMPLICIT_BOXING_IN_IDENTITY_EQUALS")
|
||||
if (other === this) return true
|
||||
if (other !is Char) return false
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
package kotlin
|
||||
|
||||
import kotlin.internal.PureReifiable
|
||||
|
||||
@@ -676,6 +676,7 @@ public class Int private constructor() : Number(), Comparable<Int> {
|
||||
* On the JVM, non-nullable values of this type are represented as values of the primitive type `float`.
|
||||
*/
|
||||
public class Float private constructor() : Number(), Comparable<Float> {
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
companion object {
|
||||
/**
|
||||
* A constant holding the smallest *positive* nonzero value of Float.
|
||||
@@ -893,6 +894,7 @@ public class Float private constructor() : Number(), Comparable<Float> {
|
||||
* On the JVM, non-nullable values of this type are represented as values of the primitive type `double`.
|
||||
*/
|
||||
public class Double private constructor() : Number(), Comparable<Double> {
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
companion object {
|
||||
/**
|
||||
* A constant holding the smallest *positive* nonzero value of Double.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("NON_ABSTRACT_FUNCTION_WITH_NO_BODY", "MUST_BE_INITIALIZED_OR_BE_ABSTRACT")
|
||||
@file:Suppress("NON_ABSTRACT_FUNCTION_WITH_NO_BODY", "MUST_BE_INITIALIZED_OR_BE_ABSTRACT", "UNUSED_PARAMETER")
|
||||
|
||||
package kotlin
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ internal fun doubleSignBit(value: Double): Int {
|
||||
}
|
||||
|
||||
internal fun getNumberHashCode(obj: Double): Int {
|
||||
@Suppress("DEPRECATED_IDENTITY_EQUALS")
|
||||
if (jsBitwiseOr(obj, 0).unsafeCast<Double>() === obj) {
|
||||
return obj.toInt()
|
||||
}
|
||||
|
||||
@@ -117,5 +117,5 @@ internal external class JsObject {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun <T, R> boxIntrinsic(x: T): R = error("Should be lowered")
|
||||
internal fun <T, R> unboxIntrinsic(x: T): R = error("Should be lowered")
|
||||
internal fun <T, R> boxIntrinsic(@Suppress("UNUSED_PARAMETER") x: T): R = error("Should be lowered")
|
||||
internal fun <T, R> unboxIntrinsic(@Suppress("UNUSED_PARAMETER") x: T): R = error("Should be lowered")
|
||||
|
||||
@@ -10,5 +10,5 @@ internal fun <T : Enum<T>> enumValuesIntrinsic(): Array<T> =
|
||||
throw IllegalStateException("Should be replaced by compiler")
|
||||
|
||||
@PublishedApi
|
||||
internal fun <T : Enum<T>> enumValueOfIntrinsic(name: String): T =
|
||||
internal fun <T : Enum<T>> enumValueOfIntrinsic(@Suppress("UNUSED_PARAMETER") name: String): T =
|
||||
throw IllegalStateException("Should be replaced by compiler")
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
package kotlin
|
||||
|
||||
/**
|
||||
|
||||
@@ -286,6 +286,7 @@ internal fun Long.divide(other: Long): Long {
|
||||
internal fun Long.modulo(other: Long) = subtract(div(other).multiply(other))
|
||||
|
||||
internal fun Long.shiftLeft(numBits: Int): Long {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val numBits = numBits and 63
|
||||
if (numBits == 0) {
|
||||
return this
|
||||
@@ -299,6 +300,7 @@ internal fun Long.shiftLeft(numBits: Int): Long {
|
||||
}
|
||||
|
||||
internal fun Long.shiftRight(numBits: Int): Long {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val numBits = numBits and 63
|
||||
if (numBits == 0) {
|
||||
return this
|
||||
@@ -312,6 +314,7 @@ internal fun Long.shiftRight(numBits: Int): Long {
|
||||
}
|
||||
|
||||
internal fun Long.shiftRightUnsigned(numBits: Int): Long {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val numBits = numBits and 63
|
||||
if (numBits == 0) {
|
||||
return this
|
||||
|
||||
@@ -51,6 +51,7 @@ internal fun <T> taggedArrayCopy(array: dynamic): T {
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
internal inline fun withType(type: String, array: dynamic): dynamic {
|
||||
array.`$type$` = type
|
||||
return array
|
||||
|
||||
@@ -7,15 +7,15 @@ package kotlin.js
|
||||
|
||||
internal fun numberToByte(a: dynamic): Byte = toByte(numberToInt(a))
|
||||
|
||||
internal fun numberToDouble(a: dynamic): Double = js("+a").unsafeCast<Double>()
|
||||
internal fun numberToDouble(@Suppress("UNUSED_PARAMETER") a: dynamic): Double = js("+a").unsafeCast<Double>()
|
||||
|
||||
internal fun numberToInt(a: dynamic): Int = if (a is Long) a.toInt() else doubleToInt(a)
|
||||
|
||||
internal fun numberToShort(a: dynamic): Short = toShort(numberToInt(a))
|
||||
|
||||
// << and >> shifts are used to preserve sign of the number
|
||||
internal fun toByte(a: dynamic): Byte = js("a << 24 >> 24").unsafeCast<Byte>()
|
||||
internal fun toShort(a: dynamic): Short = js("a << 16 >> 16").unsafeCast<Short>()
|
||||
internal fun toByte(@Suppress("UNUSED_PARAMETER") a: dynamic): Byte = js("a << 24 >> 24").unsafeCast<Byte>()
|
||||
internal fun toShort(@Suppress("UNUSED_PARAMETER") a: dynamic): Short = js("a << 16 >> 16").unsafeCast<Short>()
|
||||
|
||||
internal fun numberToLong(a: dynamic): Long = if (a is Long) a else fromNumber(a)
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ private fun getKPropMetadata(paramCount: Int, setter: Any?, type: dynamic): dyna
|
||||
return mdata
|
||||
}
|
||||
|
||||
inline private fun metadataObject(): dynamic = js("{ kind: 'class', interfaces: [] }")
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
private inline fun metadataObject(): dynamic = js("{ kind: 'class', interfaces: [] }")
|
||||
|
||||
private val propertyRefClassMetadataCache: Array<Array<dynamic>> = arrayOf<Array<dynamic>>(
|
||||
// immutable , mutable
|
||||
|
||||
@@ -76,6 +76,7 @@ public fun isInterface(ctor: dynamic, IType: dynamic): Boolean {
|
||||
|
||||
internal fun isSuspendFunction(obj: dynamic, arity: Int): Boolean {
|
||||
if (jsTypeOf(obj) == "function") {
|
||||
@Suppress("DEPRECATED_IDENTITY_EQUALS")
|
||||
return obj.`$arity`.unsafeCast<Int>() === arity
|
||||
}
|
||||
|
||||
@@ -106,7 +107,7 @@ internal fun isArrayish(o: dynamic) =
|
||||
isJsArray(o) || js("ArrayBuffer").isView(o).unsafeCast<Boolean>()
|
||||
|
||||
|
||||
internal fun isChar(c: Any): Boolean {
|
||||
internal fun isChar(@Suppress("UNUSED_PARAMETER") c: Any): Boolean {
|
||||
error("isChar is not implemented")
|
||||
}
|
||||
|
||||
|
||||
@@ -173,10 +173,12 @@ public actual fun CharArray.asList(): List<Char> {
|
||||
return this@asList[index]
|
||||
}
|
||||
override fun indexOf(element: Char): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is Char) return -1
|
||||
return this@asList.indexOf(element)
|
||||
}
|
||||
override fun lastIndexOf(element: Char): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is Char) return -1
|
||||
return this@asList.lastIndexOf(element)
|
||||
}
|
||||
|
||||
@@ -73,10 +73,12 @@ public actual fun UIntArray.asList(): List<UInt> {
|
||||
return this@asList[index]
|
||||
}
|
||||
override fun indexOf(element: UInt): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UInt) return -1
|
||||
return this@asList.indexOf(element)
|
||||
}
|
||||
override fun lastIndexOf(element: UInt): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UInt) return -1
|
||||
return this@asList.lastIndexOf(element)
|
||||
}
|
||||
@@ -98,10 +100,12 @@ public actual fun ULongArray.asList(): List<ULong> {
|
||||
return this@asList[index]
|
||||
}
|
||||
override fun indexOf(element: ULong): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is ULong) return -1
|
||||
return this@asList.indexOf(element)
|
||||
}
|
||||
override fun lastIndexOf(element: ULong): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is ULong) return -1
|
||||
return this@asList.lastIndexOf(element)
|
||||
}
|
||||
@@ -123,10 +127,12 @@ public actual fun UByteArray.asList(): List<UByte> {
|
||||
return this@asList[index]
|
||||
}
|
||||
override fun indexOf(element: UByte): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UByte) return -1
|
||||
return this@asList.indexOf(element)
|
||||
}
|
||||
override fun lastIndexOf(element: UByte): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UByte) return -1
|
||||
return this@asList.lastIndexOf(element)
|
||||
}
|
||||
@@ -148,10 +154,12 @@ public actual fun UShortArray.asList(): List<UShort> {
|
||||
return this@asList[index]
|
||||
}
|
||||
override fun indexOf(element: UShort): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UShort) return -1
|
||||
return this@asList.indexOf(element)
|
||||
}
|
||||
override fun lastIndexOf(element: UShort): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UShort) return -1
|
||||
return this@asList.lastIndexOf(element)
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ internal fun subSequence(c: CharSequence, startIndex: Int, endIndex: Int): CharS
|
||||
}
|
||||
|
||||
@JsName("captureStack")
|
||||
internal fun captureStack(baseClass: JsClass<in Throwable>, instance: Throwable) {
|
||||
internal fun captureStack(@Suppress("UNUSED_PARAMETER") baseClass: JsClass<in Throwable>, instance: Throwable) {
|
||||
if (js("Error").captureStackTrace) {
|
||||
// Using uncropped stack traces due to KT-37563.
|
||||
// Precise stack traces are implemented in JS IR compiler and stdlib
|
||||
|
||||
@@ -9,6 +9,8 @@ package kotlin.js
|
||||
// Used for js.translator/testData/box/number/mulInt32.kt
|
||||
@library
|
||||
@JsName("imulEmulated")
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
internal fun imul(x: Int, y: Int): Int = definedExternally
|
||||
|
||||
internal inline fun isArrayish(o: dynamic) = js("Kotlin").isArrayish(o)
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
internal inline fun isArrayish(o: dynamic) = js("Kotlin").isArrayish(o)
|
||||
|
||||
@@ -61,6 +61,7 @@ public actual fun Float.toRawBits(): Int = definedExternally
|
||||
public actual inline fun Float.Companion.fromBits(bits: Int): Float = js("Kotlin").floatFromBits(bits).unsafeCast<Float>()
|
||||
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
internal inline fun Long(low: Int, high: Int) = js("Kotlin").Long.fromBits(low, high).unsafeCast<Long>()
|
||||
internal inline val Long.low: Int get() = this.asDynamic().getLowBits().unsafeCast<Int>()
|
||||
internal inline val Long.high: Int get() = this.asDynamic().getHighBits().unsafeCast<Int>()
|
||||
internal inline val Long.high: Int get() = this.asDynamic().getHighBits().unsafeCast<Int>()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@PublishedApi
|
||||
internal fun <T : Annotation> KClass<*>.findAssociatedObject(annotationClass: KClass<T>): Any? {
|
||||
internal fun <T : Annotation> KClass<*>.findAssociatedObject(@Suppress("UNUSED_PARAMETER") annotationClass: KClass<T>): Any? {
|
||||
// This API is not supported in js-v1. Return `null` to be source-compatible with js-ir.
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,10 +173,12 @@ public actual fun CharArray.asList(): List<Char> {
|
||||
return this@asList[index]
|
||||
}
|
||||
override fun indexOf(element: Char): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is Char) return -1
|
||||
return this@asList.indexOf(element)
|
||||
}
|
||||
override fun lastIndexOf(element: Char): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is Char) return -1
|
||||
return this@asList.lastIndexOf(element)
|
||||
}
|
||||
|
||||
@@ -73,10 +73,12 @@ public actual fun UIntArray.asList(): List<UInt> {
|
||||
return this@asList[index]
|
||||
}
|
||||
override fun indexOf(element: UInt): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UInt) return -1
|
||||
return this@asList.indexOf(element)
|
||||
}
|
||||
override fun lastIndexOf(element: UInt): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UInt) return -1
|
||||
return this@asList.lastIndexOf(element)
|
||||
}
|
||||
@@ -98,10 +100,12 @@ public actual fun ULongArray.asList(): List<ULong> {
|
||||
return this@asList[index]
|
||||
}
|
||||
override fun indexOf(element: ULong): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is ULong) return -1
|
||||
return this@asList.indexOf(element)
|
||||
}
|
||||
override fun lastIndexOf(element: ULong): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is ULong) return -1
|
||||
return this@asList.lastIndexOf(element)
|
||||
}
|
||||
@@ -123,10 +127,12 @@ public actual fun UByteArray.asList(): List<UByte> {
|
||||
return this@asList[index]
|
||||
}
|
||||
override fun indexOf(element: UByte): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UByte) return -1
|
||||
return this@asList.indexOf(element)
|
||||
}
|
||||
override fun lastIndexOf(element: UByte): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UByte) return -1
|
||||
return this@asList.lastIndexOf(element)
|
||||
}
|
||||
@@ -148,10 +154,12 @@ public actual fun UShortArray.asList(): List<UShort> {
|
||||
return this@asList[index]
|
||||
}
|
||||
override fun indexOf(element: UShort): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UShort) return -1
|
||||
return this@asList.indexOf(element)
|
||||
}
|
||||
override fun lastIndexOf(element: UShort): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UShort) return -1
|
||||
return this@asList.lastIndexOf(element)
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ private class TypeVariableImpl(private val typeParameter: KTypeParameter) : Type
|
||||
|
||||
// [TypeVariable] extends [AnnotatedElement] starting from JDK 8. The following are copies of methods from there.
|
||||
// Suppression of VIRTUAL_MEMBER_HIDDEN is needed for cases when environment variable JDK_16 points to JDK 8+.
|
||||
@Suppress("VIRTUAL_MEMBER_HIDDEN")
|
||||
@Suppress("VIRTUAL_MEMBER_HIDDEN", "UNUSED_PARAMETER")
|
||||
fun <T : Annotation> getAnnotation(annotationClass: Class<T>): T? = null
|
||||
|
||||
@Suppress("VIRTUAL_MEMBER_HIDDEN")
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("StringsKt")
|
||||
@file:Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
|
||||
package kotlin.text
|
||||
|
||||
|
||||
@@ -299,7 +299,6 @@ public inline fun <R, T : R> Result<T>.recover(transform: (exception: Throwable)
|
||||
@InlineOnly
|
||||
@SinceKotlin("1.3")
|
||||
public inline fun <R, T : R> Result<T>.recoverCatching(transform: (exception: Throwable) -> R): Result<R> {
|
||||
val value = value // workaround for inline classes BE bug
|
||||
return when (val exception = exceptionOrNull()) {
|
||||
null -> this
|
||||
else -> runCatching { transform(exception) }
|
||||
|
||||
@@ -50,6 +50,7 @@ internal constructor(@PublishedApi internal val storage: ByteArray) : Collection
|
||||
override fun contains(element: UByte): Boolean {
|
||||
// TODO: Eliminate this check after KT-30016 gets fixed.
|
||||
// Currently JS BE does not generate special bridge method for this method.
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UByte) return false
|
||||
|
||||
return storage.contains(element.toByte())
|
||||
|
||||
@@ -50,6 +50,7 @@ internal constructor(@PublishedApi internal val storage: IntArray) : Collection<
|
||||
override fun contains(element: UInt): Boolean {
|
||||
// TODO: Eliminate this check after KT-30016 gets fixed.
|
||||
// Currently JS BE does not generate special bridge method for this method.
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UInt) return false
|
||||
|
||||
return storage.contains(element.toInt())
|
||||
|
||||
@@ -50,6 +50,7 @@ internal constructor(@PublishedApi internal val storage: LongArray) : Collection
|
||||
override fun contains(element: ULong): Boolean {
|
||||
// TODO: Eliminate this check after KT-30016 gets fixed.
|
||||
// Currently JS BE does not generate special bridge method for this method.
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is ULong) return false
|
||||
|
||||
return storage.contains(element.toLong())
|
||||
|
||||
@@ -50,6 +50,7 @@ internal constructor(@PublishedApi internal val storage: ShortArray) : Collectio
|
||||
override fun contains(element: UShort): Boolean {
|
||||
// TODO: Eliminate this check after KT-30016 gets fixed.
|
||||
// Currently JS BE does not generate special bridge method for this method.
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is UShort) return false
|
||||
|
||||
return storage.contains(element.toShort())
|
||||
|
||||
@@ -1509,10 +1509,12 @@ object ArrayOps : TemplateGroupBase() {
|
||||
return this@asList[index]
|
||||
}
|
||||
override fun indexOf(element: T): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is T) return -1
|
||||
return this@asList.indexOf(element)
|
||||
}
|
||||
override fun lastIndexOf(element: T): Int {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((element as Any?) !is T) return -1
|
||||
return this@asList.lastIndexOf(element)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user