Cleanup warnings in stdlib and generated code

This commit is contained in:
Ilya Gorbunov
2017-04-12 09:10:33 +03:00
parent 6af986cfdd
commit 8f452ed046
24 changed files with 74 additions and 6 deletions
@@ -2158,6 +2158,7 @@ public inline fun <T> Array<out T>.single(predicate: (T) -> Boolean): T {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as T return single as T
} }
@@ -2175,6 +2176,7 @@ public inline fun ByteArray.single(predicate: (Byte) -> Boolean): Byte {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Byte return single as Byte
} }
@@ -2192,6 +2194,7 @@ public inline fun ShortArray.single(predicate: (Short) -> Boolean): Short {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Short return single as Short
} }
@@ -2209,6 +2212,7 @@ public inline fun IntArray.single(predicate: (Int) -> Boolean): Int {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Int return single as Int
} }
@@ -2226,6 +2230,7 @@ public inline fun LongArray.single(predicate: (Long) -> Boolean): Long {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Long return single as Long
} }
@@ -2243,6 +2248,7 @@ public inline fun FloatArray.single(predicate: (Float) -> Boolean): Float {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Float return single as Float
} }
@@ -2260,6 +2266,7 @@ public inline fun DoubleArray.single(predicate: (Double) -> Boolean): Double {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Double return single as Double
} }
@@ -2277,6 +2284,7 @@ public inline fun BooleanArray.single(predicate: (Boolean) -> Boolean): Boolean
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Boolean return single as Boolean
} }
@@ -2294,6 +2302,7 @@ public inline fun CharArray.single(predicate: (Char) -> Boolean): Char {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Char return single as Char
} }
@@ -255,6 +255,7 @@ public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.indexOf(element: T):
/** /**
* Returns first index of [element], or -1 if the list does not contain element. * Returns first index of [element], or -1 if the list does not contain element.
*/ */
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases
public fun <@kotlin.internal.OnlyInputTypes T> List<T>.indexOf(element: T): Int { public fun <@kotlin.internal.OnlyInputTypes T> List<T>.indexOf(element: T): Int {
return indexOf(element) return indexOf(element)
} }
@@ -355,6 +356,7 @@ public inline fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T {
} }
} }
if (!found) throw NoSuchElementException("Collection contains no element matching the predicate.") if (!found) throw NoSuchElementException("Collection contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return last as T return last as T
} }
@@ -389,6 +391,7 @@ public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.lastIndexOf(element:
/** /**
* Returns last index of [element], or -1 if the list does not contain element. * Returns last index of [element], or -1 if the list does not contain element.
*/ */
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases
public fun <@kotlin.internal.OnlyInputTypes T> List<T>.lastIndexOf(element: T): Int { public fun <@kotlin.internal.OnlyInputTypes T> List<T>.lastIndexOf(element: T): Int {
return lastIndexOf(element) return lastIndexOf(element)
} }
@@ -486,6 +489,7 @@ public inline fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T {
} }
} }
if (!found) throw NoSuchElementException("Collection contains no element matching the predicate.") if (!found) throw NoSuchElementException("Collection contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as T return single as T
} }
@@ -209,6 +209,7 @@ public inline fun <T> Sequence<T>.last(predicate: (T) -> Boolean): T {
} }
} }
if (!found) throw NoSuchElementException("Sequence contains no element matching the predicate.") if (!found) throw NoSuchElementException("Sequence contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return last as T return last as T
} }
@@ -289,6 +290,7 @@ public inline fun <T> Sequence<T>.single(predicate: (T) -> Boolean): T {
} }
} }
if (!found) throw NoSuchElementException("Sequence contains no element matching the predicate.") if (!found) throw NoSuchElementException("Sequence contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as T return single as T
} }
@@ -189,6 +189,7 @@ public inline fun CharSequence.single(predicate: (Char) -> Boolean): Char {
} }
} }
if (!found) throw NoSuchElementException("Char sequence contains no character matching the predicate.") if (!found) throw NoSuchElementException("Char sequence contains no character matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Char return single as Char
} }
@@ -148,6 +148,7 @@ public header fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.indexOf(elemen
/** /**
* Returns first index of [element], or -1 if the list does not contain element. * Returns first index of [element], or -1 if the list does not contain element.
*/ */
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases
public header fun <@kotlin.internal.OnlyInputTypes T> List<T>.indexOf(element: T): Int public header fun <@kotlin.internal.OnlyInputTypes T> List<T>.indexOf(element: T): Int
/** /**
@@ -202,6 +203,7 @@ public header fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.lastIndexOf(el
/** /**
* Returns last index of [element], or -1 if the list does not contain element. * Returns last index of [element], or -1 if the list does not contain element.
*/ */
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases
public header fun <@kotlin.internal.OnlyInputTypes T> List<T>.lastIndexOf(element: T): Int public header fun <@kotlin.internal.OnlyInputTypes T> List<T>.lastIndexOf(element: T): Int
/** /**
+10
View File
@@ -2156,6 +2156,7 @@ public inline fun <T> Array<out T>.single(predicate: (T) -> Boolean): T {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as T return single as T
} }
@@ -2173,6 +2174,7 @@ public inline fun ByteArray.single(predicate: (Byte) -> Boolean): Byte {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Byte return single as Byte
} }
@@ -2190,6 +2192,7 @@ public inline fun ShortArray.single(predicate: (Short) -> Boolean): Short {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Short return single as Short
} }
@@ -2207,6 +2210,7 @@ public inline fun IntArray.single(predicate: (Int) -> Boolean): Int {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Int return single as Int
} }
@@ -2224,6 +2228,7 @@ public inline fun LongArray.single(predicate: (Long) -> Boolean): Long {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Long return single as Long
} }
@@ -2241,6 +2246,7 @@ public inline fun FloatArray.single(predicate: (Float) -> Boolean): Float {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Float return single as Float
} }
@@ -2258,6 +2264,7 @@ public inline fun DoubleArray.single(predicate: (Double) -> Boolean): Double {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Double return single as Double
} }
@@ -2275,6 +2282,7 @@ public inline fun BooleanArray.single(predicate: (Boolean) -> Boolean): Boolean
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Boolean return single as Boolean
} }
@@ -2292,6 +2300,7 @@ public inline fun CharArray.single(predicate: (Char) -> Boolean): Char {
} }
} }
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Char return single as Char
} }
@@ -13663,6 +13672,7 @@ public fun CharArray.sort(): Unit {
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun <T: Comparable<T>> Array<out T>.sort(): Unit { public inline fun <T: Comparable<T>> Array<out T>.sort(): Unit {
@Suppress("UNCHECKED_CAST")
(this as Array<Any?>).sort() (this as Array<Any?>).sort()
} }
@@ -255,6 +255,7 @@ public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.indexOf(element: T):
/** /**
* Returns first index of [element], or -1 if the list does not contain element. * Returns first index of [element], or -1 if the list does not contain element.
*/ */
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases
public fun <@kotlin.internal.OnlyInputTypes T> List<T>.indexOf(element: T): Int { public fun <@kotlin.internal.OnlyInputTypes T> List<T>.indexOf(element: T): Int {
return indexOf(element) return indexOf(element)
} }
@@ -355,6 +356,7 @@ public inline fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T {
} }
} }
if (!found) throw NoSuchElementException("Collection contains no element matching the predicate.") if (!found) throw NoSuchElementException("Collection contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return last as T return last as T
} }
@@ -389,6 +391,7 @@ public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.lastIndexOf(element:
/** /**
* Returns last index of [element], or -1 if the list does not contain element. * Returns last index of [element], or -1 if the list does not contain element.
*/ */
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases
public fun <@kotlin.internal.OnlyInputTypes T> List<T>.lastIndexOf(element: T): Int { public fun <@kotlin.internal.OnlyInputTypes T> List<T>.lastIndexOf(element: T): Int {
return lastIndexOf(element) return lastIndexOf(element)
} }
@@ -486,6 +489,7 @@ public inline fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T {
} }
} }
if (!found) throw NoSuchElementException("Collection contains no element matching the predicate.") if (!found) throw NoSuchElementException("Collection contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as T return single as T
} }
@@ -209,6 +209,7 @@ public inline fun <T> Sequence<T>.last(predicate: (T) -> Boolean): T {
} }
} }
if (!found) throw NoSuchElementException("Sequence contains no element matching the predicate.") if (!found) throw NoSuchElementException("Sequence contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return last as T return last as T
} }
@@ -289,6 +290,7 @@ public inline fun <T> Sequence<T>.single(predicate: (T) -> Boolean): T {
} }
} }
if (!found) throw NoSuchElementException("Sequence contains no element matching the predicate.") if (!found) throw NoSuchElementException("Sequence contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as T return single as T
} }
@@ -189,6 +189,7 @@ public inline fun CharSequence.single(predicate: (Char) -> Boolean): Char {
} }
} }
if (!found) throw NoSuchElementException("Char sequence contains no character matching the predicate.") if (!found) throw NoSuchElementException("Char sequence contains no character matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as Char return single as Char
} }
@@ -28,6 +28,7 @@ public abstract class AbstractIterator<T>: Iterator<T> {
override fun next(): T { override fun next(): T {
if (!hasNext()) throw NoSuchElementException() if (!hasNext()) throw NoSuchElementException()
state = State.NotReady state = State.NotReady
@Suppress("UNCHECKED_CAST")
return nextValue as T return nextValue as T
} }
@@ -173,6 +173,7 @@ public inline fun <T> java.util.Enumeration<T>.toList(): List<T> = java.util.Col
* *
* Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection<E>`. * Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection<E>`.
*/ */
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun <@kotlin.internal.OnlyInputTypes T> Collection<T>.containsAll(elements: Collection<T>): Boolean = this.containsAll(elements) public inline fun <@kotlin.internal.OnlyInputTypes T> Collection<T>.containsAll(elements: Collection<T>): Boolean = this.containsAll(elements)
@@ -97,6 +97,7 @@ public inline fun <T, K, R> Grouping<T, K>.fold(
initialValueSelector: (key: K, element: T) -> R, initialValueSelector: (key: K, element: T) -> R,
operation: (key: K, accumulator: R, element: T) -> R operation: (key: K, accumulator: R, element: T) -> R
): Map<K, R> = ): Map<K, R> =
@Suppress("UNCHECKED_CAST")
aggregate { key, acc, e, first -> operation(key, if (first) initialValueSelector(key, e) else acc as R, e) } aggregate { key, acc, e, first -> operation(key, if (first) initialValueSelector(key, e) else acc as R, e) }
/** /**
@@ -126,6 +127,7 @@ public inline fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(
initialValueSelector: (key: K, element: T) -> R, initialValueSelector: (key: K, element: T) -> R,
operation: (key: K, accumulator: R, element: T) -> R operation: (key: K, accumulator: R, element: T) -> R
): M = ): M =
@Suppress("UNCHECKED_CAST")
aggregateTo(destination) { key, acc, e, first -> operation(key, if (first) initialValueSelector(key, e) else acc as R, e) } aggregateTo(destination) { key, acc, e, first -> operation(key, if (first) initialValueSelector(key, e) else acc as R, e) }
@@ -145,6 +147,7 @@ public inline fun <T, K, R> Grouping<T, K>.fold(
initialValue: R, initialValue: R,
operation: (accumulator: R, element: T) -> R operation: (accumulator: R, element: T) -> R
): Map<K, R> = ): Map<K, R> =
@Suppress("UNCHECKED_CAST")
aggregate { _, acc, e, first -> operation(if (first) initialValue else acc as R, e) } aggregate { _, acc, e, first -> operation(if (first) initialValue else acc as R, e) }
/** /**
@@ -168,6 +171,7 @@ public inline fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(
initialValue: R, initialValue: R,
operation: (accumulator: R, element: T) -> R operation: (accumulator: R, element: T) -> R
): M = ): M =
@Suppress("UNCHECKED_CAST")
aggregateTo(destination) { _, acc, e, first -> operation(if (first) initialValue else acc as R, e) } aggregateTo(destination) { _, acc, e, first -> operation(if (first) initialValue else acc as R, e) }
@@ -190,6 +194,7 @@ public inline fun <S, T : S, K> Grouping<T, K>.reduce(
operation: (key: K, accumulator: S, element: T) -> S operation: (key: K, accumulator: S, element: T) -> S
): Map<K, S> = ): Map<K, S> =
aggregate { key, acc, e, first -> aggregate { key, acc, e, first ->
@Suppress("UNCHECKED_CAST")
if (first) e else operation(key, acc as S, e) if (first) e else operation(key, acc as S, e)
} }
@@ -216,6 +221,7 @@ public inline fun <S, T : S, K, M : MutableMap<in K, S>> Grouping<T, K>.reduceTo
operation: (key: K, accumulator: S, element: T) -> S operation: (key: K, accumulator: S, element: T) -> S
): M = ): M =
aggregateTo(destination) { key, acc, e, first -> aggregateTo(destination) { key, acc, e, first ->
@Suppress("UNCHECKED_CAST")
if (first) e else operation(key, acc as S, e) if (first) e else operation(key, acc as S, e)
} }
@@ -283,6 +289,7 @@ public inline fun <T, K, M : MutableMap<in K, Int>> Grouping<T, K>.eachSumOfTo(d
@JvmVersion @JvmVersion
@PublishedApi @PublishedApi
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
@Suppress("UNCHECKED_CAST") // tricks with erased generics go here, do not repeat at reified platforms
internal inline fun <K, V, R> MutableMap<K, V>.mapValuesInPlace(f: (Map.Entry<K, V>) -> R): MutableMap<K, R> { internal inline fun <K, V, R> MutableMap<K, V>.mapValuesInPlace(f: (Map.Entry<K, V>) -> R): MutableMap<K, R> {
entries.forEach { entries.forEach {
(it as MutableMap.MutableEntry<K, R>).setValue(f(it)) (it as MutableMap.MutableEntry<K, R>).setValue(f(it))
@@ -175,6 +175,7 @@ public inline fun <@kotlin.internal.OnlyInputTypes K> Map<out K, *>.containsKey(
* *
* Allows to overcome type-safety restriction of `containsValue` that requires to pass a value of type `V`. * Allows to overcome type-safety restriction of `containsValue` that requires to pass a value of type `V`.
*/ */
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun <K, @kotlin.internal.OnlyInputTypes V> Map<K, V>.containsValue(value: V): Boolean = this.containsValue(value) public inline fun <K, @kotlin.internal.OnlyInputTypes V> Map<K, V>.containsValue(value: V): Boolean = this.containsValue(value)
@@ -235,6 +236,7 @@ internal inline fun <K, V> Map<K, V>.getOrElseNullable(key: K, defaultValue: ()
if (value == null && !containsKey(key)) { if (value == null && !containsKey(key)) {
return defaultValue() return defaultValue()
} else { } else {
@Suppress("UNCHECKED_CAST")
return value as V return value as V
} }
} }
@@ -48,11 +48,13 @@ public inline fun <T> MutableList<T>.remove(index: Int): T = removeAt(index)
@Deprecated("Use sortWith(comparator) instead.", ReplaceWith("this.sortWith(comparator)"), level = DeprecationLevel.ERROR) @Deprecated("Use sortWith(comparator) instead.", ReplaceWith("this.sortWith(comparator)"), level = DeprecationLevel.ERROR)
@JvmVersion @JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
@Suppress("UNUSED_PARAMETER")
public inline fun <T> MutableList<T>.sort(comparator: Comparator<in T>): Unit = throw NotImplementedError() public inline fun <T> MutableList<T>.sort(comparator: Comparator<in T>): Unit = throw NotImplementedError()
@Deprecated("Use sortWith(Comparator(comparison)) instead.", ReplaceWith("this.sortWith(Comparator(comparison))"), level = DeprecationLevel.ERROR) @Deprecated("Use sortWith(Comparator(comparison)) instead.", ReplaceWith("this.sortWith(Comparator(comparison))"), level = DeprecationLevel.ERROR)
@JvmVersion @JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
@Suppress("UNUSED_PARAMETER")
public inline fun <T> MutableList<T>.sort(comparison: (T, T) -> Int): Unit = throw NotImplementedError() public inline fun <T> MutableList<T>.sort(comparison: (T, T) -> Int): Unit = throw NotImplementedError()
/** /**
@@ -123,6 +123,7 @@ internal class FilteringSequence<T>(private val sequence: Sequence<T>,
val result = nextItem val result = nextItem
nextItem = null nextItem = null
nextState = -1 nextState = -1
@Suppress("UNCHECKED_CAST")
return result as T return result as T
} }
@@ -380,6 +381,7 @@ internal class TakeWhileSequence<T>
calcNext() // will change nextState calcNext() // will change nextState
if (nextState == 0) if (nextState == 0)
throw NoSuchElementException() throw NoSuchElementException()
@Suppress("UNCHECKED_CAST")
val result = nextItem as T val result = nextItem as T
// Clean next to avoid keeping reference on yielded instance // Clean next to avoid keeping reference on yielded instance
@@ -466,6 +468,7 @@ internal class DropWhileSequence<T>
drop() drop()
if (dropState == 1) { if (dropState == 1) {
@Suppress("UNCHECKED_CAST")
val result = nextItem as T val result = nextItem as T
nextItem = null nextItem = null
dropState = 0 dropState = 0
@@ -100,6 +100,7 @@ internal inline fun processBareContinuationResume(completion: Continuation<*>, b
try { try {
val result = block() val result = block()
if (result !== COROUTINE_SUSPENDED) { if (result !== COROUTINE_SUSPENDED) {
@Suppress("UNCHECKED_CAST")
(completion as Continuation<Any?>).resume(result) (completion as Continuation<Any?>).resume(result)
} }
} catch (t: Throwable) { } catch (t: Throwable) {
@@ -138,6 +138,7 @@ private class SequenceBuilderIterator<T> : SequenceBuilder<T>(), Iterator<T>, Co
} }
State_Ready -> { State_Ready -> {
state = State_NotReady state = State_NotReady
@Suppress("UNCHECKED_CAST")
val result = nextValue as T val result = nextValue as T
nextValue = null nextValue = null
return result return result
@@ -41,7 +41,9 @@ import kotlin.coroutines.experimental.processBareContinuationResume
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline suspend fun <T> suspendCoroutineOrReturn(crossinline block: (Continuation<T>) -> Any?): T = null!! @Suppress("UNUSED_PARAMETER")
public inline suspend fun <T> suspendCoroutineOrReturn(crossinline block: (Continuation<T>) -> Any?): T =
throw NotImplementedError("Implementation is intrinsic")
/** /**
* This value is used as a return value of [suspendCoroutineOrReturn] `block` argument to state that * This value is used as a return value of [suspendCoroutineOrReturn] `block` argument to state that
@@ -69,6 +71,7 @@ public fun <T> (suspend () -> T).createCoroutineUnchecked(
): Continuation<Unit> = ): Continuation<Unit> =
if (this !is kotlin.coroutines.experimental.jvm.internal.CoroutineImpl) if (this !is kotlin.coroutines.experimental.jvm.internal.CoroutineImpl)
buildContinuationByInvokeCall(completion) { buildContinuationByInvokeCall(completion) {
@Suppress("UNCHECKED_CAST")
(this as Function1<Continuation<T>, Any?>).invoke(completion) (this as Function1<Continuation<T>, Any?>).invoke(completion)
} }
else else
@@ -92,6 +95,7 @@ public fun <R, T> (suspend R.() -> T).createCoroutineUnchecked(
): Continuation<Unit> = ): Continuation<Unit> =
if (this !is kotlin.coroutines.experimental.jvm.internal.CoroutineImpl) if (this !is kotlin.coroutines.experimental.jvm.internal.CoroutineImpl)
buildContinuationByInvokeCall(completion) { buildContinuationByInvokeCall(completion) {
@Suppress("UNCHECKED_CAST")
(this as Function2<R, Continuation<T>, Any?>).invoke(receiver, completion) (this as Function2<R, Continuation<T>, Any?>).invoke(receiver, completion)
} }
else else
@@ -240,7 +240,7 @@ private class TerminateException(file: File) : FileSystemException(file) {}
public fun File.copyRecursively(target: File, public fun File.copyRecursively(target: File,
overwrite: Boolean = false, overwrite: Boolean = false,
onError: (File, IOException) -> OnErrorAction = onError: (File, IOException) -> OnErrorAction =
{ file, exception -> throw exception } { _, exception -> throw exception }
): Boolean { ): Boolean {
if (!exists()) { if (!exists()) {
return onError(this, NoSuchFileException(file = this, reason = "The source file doesn't exist.")) != return onError(this, NoSuchFileException(file = this, reason = "The source file doesn't exist.")) !=
+3 -3
View File
@@ -36,11 +36,11 @@ public inline operator fun Char.plus(other: String) : String = this.toString() +
* - Applying the method [toLowerCase] to each character produces the same result * - Applying the method [toLowerCase] to each character produces the same result
*/ */
public fun Char.equals(other: Char, ignoreCase: Boolean = false): Boolean { public fun Char.equals(other: Char, ignoreCase: Boolean = false): Boolean {
if (this === other) return true if (this == other) return true
if (!ignoreCase) return false if (!ignoreCase) return false
if (this.toUpperCase() === other.toUpperCase()) return true if (this.toUpperCase() == other.toUpperCase()) return true
if (this.toLowerCase() === other.toLowerCase()) return true if (this.toLowerCase() == other.toLowerCase()) return true
return false return false
} }
@@ -308,6 +308,7 @@ public fun CharSequence.subSequence(range: IntRange): CharSequence = subSequence
* Replace parameter names with the same as those of [CharSequence.subSequence]. * Replace parameter names with the same as those of [CharSequence.subSequence].
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning
@Deprecated("Use parameters named startIndex and endIndex.", ReplaceWith("subSequence(startIndex = start, endIndex = end)")) @Deprecated("Use parameters named startIndex and endIndex.", ReplaceWith("subSequence(startIndex = start, endIndex = end)"))
public inline fun String.subSequence(start: Int, end: Int): CharSequence = subSequence(start, end) public inline fun String.subSequence(start: Int, end: Int): CharSequence = subSequence(start, end)
@@ -11,18 +11,21 @@ import kotlin.internal.*
/** /**
* Prints the stack trace of this throwable to the standard output. * Prints the stack trace of this throwable to the standard output.
*/ */
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // to be used when no member available
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Throwable.printStackTrace(): Unit = (this as java.lang.Throwable).printStackTrace() public inline fun Throwable.printStackTrace(): Unit = (this as java.lang.Throwable).printStackTrace()
/** /**
* Prints the stack trace of this throwable to the specified [writer]. * Prints the stack trace of this throwable to the specified [writer].
*/ */
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // to be used when no member available
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Throwable.printStackTrace(writer: PrintWriter): Unit = (this as java.lang.Throwable).printStackTrace(writer) public inline fun Throwable.printStackTrace(writer: PrintWriter): Unit = (this as java.lang.Throwable).printStackTrace(writer)
/** /**
* Prints the stack trace of this throwable to the specified [stream]. * Prints the stack trace of this throwable to the specified [stream].
*/ */
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // to be used when no member available
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Throwable.printStackTrace(stream: PrintStream): Unit = (this as java.lang.Throwable).printStackTrace(stream) public inline fun Throwable.printStackTrace(stream: PrintStream): Unit = (this as java.lang.Throwable).printStackTrace(stream)
@@ -33,6 +33,7 @@ fun elements(): List<GenericFunction> {
only(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives, Lists) only(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives, Lists)
doc { f -> "Returns first index of [element], or -1 if the ${f.collection} does not contain element." } doc { f -> "Returns first index of [element], or -1 if the ${f.collection} does not contain element." }
typeParam("@kotlin.internal.OnlyInputTypes T") typeParam("@kotlin.internal.OnlyInputTypes T")
annotations(Lists) { """@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases""" }
returns("Int") returns("Int")
body { f -> body { f ->
""" """
@@ -82,6 +83,7 @@ fun elements(): List<GenericFunction> {
only(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives, Lists) only(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives, Lists)
doc { f -> "Returns last index of [element], or -1 if the ${f.collection} does not contain element." } doc { f -> "Returns last index of [element], or -1 if the ${f.collection} does not contain element." }
typeParam("@kotlin.internal.OnlyInputTypes T") typeParam("@kotlin.internal.OnlyInputTypes T")
annotations(Lists) { """@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases""" }
returns("Int") returns("Int")
body { f -> body { f ->
""" """
@@ -538,6 +540,7 @@ fun elements(): List<GenericFunction> {
} }
} }
if (!found) throw NoSuchElementException("${f.doc.collection.capitalize()} contains no ${f.doc.element} matching the predicate.") if (!found) throw NoSuchElementException("${f.doc.collection.capitalize()} contains no ${f.doc.element} matching the predicate.")
@Suppress("UNCHECKED_CAST")
return last as T return last as T
""" """
} }
@@ -710,6 +713,7 @@ fun elements(): List<GenericFunction> {
} }
} }
if (!found) throw NoSuchElementException("${f.doc.collection.capitalize()} contains no ${f.doc.element} matching the predicate.") if (!found) throw NoSuchElementException("${f.doc.collection.capitalize()} contains no ${f.doc.element} matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as T return single as T
""" """
} }
@@ -426,7 +426,10 @@ object CommonArrays {
returns("Unit") returns("Unit")
inline(Platform.JVM, Inline.Only) inline(Platform.JVM, Inline.Only)
body(Platform.JVM) { body(Platform.JVM) {
"(this as Array<Any?>).sort()" """
@Suppress("UNCHECKED_CAST")
(this as Array<Any?>).sort()
"""
} }
body(Platform.JS) { body(Platform.JS) {
""" """