Stdlib: review and suppress warnings

This commit is contained in:
Ilya Gorbunov
2018-09-08 06:29:50 +03:00
parent 6786b9ece2
commit bf4be12239
9 changed files with 14 additions and 2 deletions
@@ -41,6 +41,7 @@ public suspend inline fun <T> suspendCoroutineOrReturn(crossinline block: (Conti
*/
@SinceKotlin("1.2")
@kotlin.internal.InlineOnly
@Suppress("UNUSED_PARAMETER", "RedundantSuspendModifier")
public suspend inline fun <T> suspendCoroutineUninterceptedOrReturn(crossinline block: (Continuation<T>) -> Any?): T =
throw NotImplementedError("Implementation of suspendCoroutineUninterceptedOrReturn is intrinsic")
@@ -54,6 +54,7 @@ internal fun <T> probeCoroutineCreated(completion: Continuation<T>): Continuatio
* parameter in this function is `Continuation<*>`. See [probeCoroutineCreated] for details.
*/
@SinceKotlin("1.3")
@Suppress("UNUSED_PARAMETER")
internal fun probeCoroutineResumed(frame: Continuation<*>) {
/** implementation of this function is replaced by debugger */
}
@@ -69,6 +70,7 @@ internal fun probeCoroutineResumed(frame: Continuation<*>) {
* parameter in this function is `Continuation<*>`. See [probeCoroutineCreated] for details.
*/
@SinceKotlin("1.3")
@Suppress("UNUSED_PARAMETER")
internal fun probeCoroutineSuspended(frame: Continuation<*>) {
/** implementation of this function is replaced by debugger */
}
@@ -28,13 +28,13 @@ private class RunSuspend : Continuation<Unit> {
override fun resumeWith(result: Result<Unit>) = synchronized(this) {
this.result = result
(this as Object).notifyAll()
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") (this as Object).notifyAll()
}
fun await() = synchronized(this) {
while (true) {
when (val result = this.result) {
null -> (this as Object).wait()
null -> @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") (this as Object).wait()
else -> {
result.getOrThrow() // throw up failure
return
@@ -36,6 +36,7 @@ import kotlin.internal.InlineOnly
*/
@SinceKotlin("1.3")
@InlineOnly
@Suppress("UNUSED_PARAMETER", "RedundantSuspendModifier")
public suspend inline fun <T> suspendCoroutineUninterceptedOrReturn(crossinline block: (Continuation<T>) -> Any?): T =
throw NotImplementedError("Implementation of suspendCoroutineUninterceptedOrReturn is intrinsic")
@@ -51,6 +51,7 @@ fun charArray(size: Int, init: dynamic): Array<Char> {
inline fun charArrayWithFun(size: Int, init: (Int) -> Char): Array<Char> {
val array = charArray(size, null)
for (i in 0..array.size - 1) {
@Suppress("UNUSED_VARIABLE") // used in js block
val value = init(i)
js("array[i] = value;")
}
@@ -61,6 +62,7 @@ inline fun charArrayWithFun(size: Int, init: (Int) -> Char): Array<Char> {
inline fun untypedCharArrayWithFun(size: Int, init: (Int) -> Char): Array<Char> {
val array = Array<Char>(size)
for (i in 0..array.size - 1) {
@Suppress("UNUSED_VARIABLE") // used in js block
val value = init(i)
js("array[i] = value;")
}
@@ -38,9 +38,11 @@ public actual open class ArrayList<E> internal constructor(private var array: Ar
public actual fun ensureCapacity(minCapacity: Int) {}
actual override val size: Int get() = array.size
@Suppress("UNCHECKED_CAST")
actual override fun get(index: Int): E = array[rangeCheck(index)] as E
actual override fun set(index: Int, element: E): E {
rangeCheck(index)
@Suppress("UNCHECKED_CAST")
return array[index].apply { array[index] = element } as E
}
@@ -34,6 +34,7 @@ internal actual inline fun copyToArrayImpl(collection: Collection<*>): Array<Any
kotlin.jvm.internal.collectionToArray(collection)
@kotlin.internal.InlineOnly
@Suppress("UNCHECKED_CAST")
internal actual inline fun <T> copyToArrayImpl(collection: Collection<*>, array: Array<T>): Array<T> =
kotlin.jvm.internal.collectionToArray(collection, array as Array<Any?>) as Array<T>
@@ -472,8 +472,10 @@ internal fun Int.takeUpperBits(bitCount: Int): Int =
this.ushr(32 - bitCount) and (-bitCount).shr(31)
internal fun checkRangeBounds(from: Int, until: Int) = require(until > from) { boundsErrorMessage(from, until) }
@ExperimentalUnsignedTypes
internal fun checkUIntRangeBounds(from: UInt, until: UInt) = require(until > from) { boundsErrorMessage(from, until) }
internal fun checkRangeBounds(from: Long, until: Long) = require(until > from) { boundsErrorMessage(from, until) }
@ExperimentalUnsignedTypes
internal fun checkULongRangeBounds(from: ULong, until: ULong) = require(until > from) { boundsErrorMessage(from, until) }
internal fun checkRangeBounds(from: Double, until: Double) = require(until > from) { boundsErrorMessage(from, until) }
@@ -45,6 +45,7 @@ class CoroutinesReferenceValuesTest {
bad.startCoroutine(object : Continuation<BadClass> {
override val context: CoroutineContext = EmptyCoroutineContext
@Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE")
override fun resumeWith(result_: Result<BadClass>) {
assertTrue(result == null)
result = result_.getOrThrow()