Cleanup warnings in stdlib-js

This commit is contained in:
Ilya Gorbunov
2017-04-12 09:12:06 +03:00
parent cb186aabf9
commit ac46f1e23d
19 changed files with 29 additions and 17 deletions
@@ -44,6 +44,7 @@ fun booleanArray(size: Int, init: dynamic): Array<Boolean> {
}
@JsName("charArray")
@Suppress("UNUSED_PARAMETER")
fun charArray(size: Int, init: dynamic): Array<Char> {
val result = js("new Uint16Array(size)")
result.`$type$` = "CharArray"
+1 -1
View File
@@ -23,7 +23,7 @@ package kotlin.jvm
internal annotation class JvmOverloads
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FILE)
@Retention(AnnotationRetention.RUNTIME)
@Retention(AnnotationRetention.SOURCE)
@MustBeDocumented
internal annotation class JvmName(public val name: String)
+2
View File
@@ -173,6 +173,7 @@ internal inline fun <T> concat(args: Array<T>): T {
*/
@PublishedApi
@JsName("arrayConcat")
@Suppress("UNUSED_PARAMETER")
internal fun <T> arrayConcat(a: T, b: T): T {
return concat(js("arguments"))
}
@@ -186,6 +187,7 @@ internal fun <T> arrayConcat(a: T, b: T): T {
*/
@PublishedApi
@JsName("primitiveArrayConcat")
@Suppress("UNUSED_PARAMETER")
internal fun <T> primitiveArrayConcat(a: T, b: T): T {
val args: Array<T> = js("arguments")
if (a is Array<*> && a.asDynamic().`$type$` === undefined) {
+1
View File
@@ -58,6 +58,7 @@ internal fun <T> copyToArrayImpl(collection: Collection<*>, array: Array<T>): Ar
}
@library("arrayToString")
@Suppress("UNUSED_PARAMETER")
internal fun arrayToString(array: Array<*>): String = definedExternally
/**
@@ -29,7 +29,7 @@ public open class ArrayList<E> internal constructor(private var array: Array<Any
* Creates an empty [ArrayList].
* @param capacity initial capacity (ignored)
*/
public constructor(capacity: Int = 0) : this(emptyArray()) {}
public constructor(@Suppress("UNUSED_PARAMETER") capacity: Int = 0) : this(emptyArray()) {}
/**
* Creates an [ArrayList] filled from the [elements] collection.
*/
@@ -38,7 +38,7 @@ public open class ArrayList<E> internal constructor(private var array: Array<Any
/** Does nothing in this ArrayList implementation. */
public fun trimToSize() {}
/** Does nothing in this ArrayList implementation. */
public fun ensureCapacity(minCapacity: Int) {}
public fun ensureCapacity(@Suppress("UNUSED_PARAMETER") minCapacity: Int) {}
override val size: Int get() = array.size
override fun get(index: Int): E = array[rangeCheck(index)] as E
@@ -46,7 +46,7 @@ internal class InternalStringMap<K, V>(override val equality: EqualityComparator
override operator fun get(key: K): V? {
if (key !is String) return null
val value = backingMap[key]
return if (value !== undefined) value as V else null
return if (value !== undefined) value.unsafeCast<V>() else null
}
@@ -62,7 +62,7 @@ internal class InternalStringMap<K, V>(override val equality: EqualityComparator
}
else {
// valueMod++
return oldValue as V
return oldValue.unsafeCast<V>()
}
}
@@ -73,7 +73,7 @@ internal class InternalStringMap<K, V>(override val equality: EqualityComparator
deleteProperty(backingMap, key)
size--
// structureChanged(host)
return value as V
return value.unsafeCast<V>()
}
else {
// valueMod++
@@ -110,9 +110,9 @@ internal class InternalStringMap<K, V>(override val equality: EqualityComparator
private fun newMapEntry(key: K): MutableEntry<K, V> = object : MutableEntry<K, V> {
override val key: K get() = key
override val value: V get() = this@InternalStringMap[key] as V
override val value: V get() = this@InternalStringMap[key].unsafeCast<V>()
override fun setValue(newValue: V): V = this@InternalStringMap.put(key, newValue) as V
override fun setValue(newValue: V): V = this@InternalStringMap.put(key, newValue).unsafeCast<V>()
override fun hashCode(): Int = AbstractMap.entryHashCode(this)
override fun toString(): String = AbstractMap.entryToString(this)
@@ -174,6 +174,7 @@ public open class LinkedHashMap<K, V> : HashMap<K, V>, Map<K, V> {
}
internal constructor(backingMap: HashMap<K, Any>) : super() {
@Suppress("UNCHECKED_CAST") // expected to work due to erasure
map = backingMap as HashMap<K, ChainEntry<K, V>>
}
+1 -1
View File
@@ -36,4 +36,4 @@ public annotation class Volatile
public annotation class Synchronized
@kotlin.internal.InlineOnly
public inline fun <R> synchronized(lock: Any, crossinline block: () -> R): R = block()
public inline fun <R> synchronized(@Suppress("UNUSED_PARAMETER") lock: Any, crossinline block: () -> R): R = block()
+1
View File
@@ -94,6 +94,7 @@ private var output = run {
if (isNode) NodeJsOutput(js("process.stdout")) else BufferedOutputToConsoleLog()
}
@kotlin.internal.InlineOnly
private inline fun String(value: Any?): String = js("String")(value)
/** Prints a newline to the standard output stream. */
+2
View File
@@ -73,9 +73,11 @@ public external fun js(code: String): dynamic
* Function corresponding to JavaScript's `typeof` operator
*/
@kotlin.internal.InlineOnly
@Suppress("UNUSED_PARAMETER")
public inline fun jsTypeOf(a: Any?): String = js("typeof a")
@kotlin.internal.InlineOnly
@Suppress("UNUSED_PARAMETER")
internal inline fun deleteProperty(obj: Any, property: Any) {
js("delete obj[property]")
}
+2 -2
View File
@@ -29,8 +29,8 @@ internal abstract class CoroutineImpl(private val resultContinuation: Continuati
val facade: Continuation<Any?> = context[ContinuationInterceptor]?.interceptContinuation(this) ?: this
override fun resume(data: Any?) {
result = data
override fun resume(value: Any?) {
result = value
doResumeWrapper()
}
+1 -1
View File
@@ -22,7 +22,7 @@ package kotlin.collections
*/
@SinceKotlin("1.1")
public fun <T, K> Grouping<T, K>.eachCount(): Map<K, Int> =
fold(0) { acc, e -> acc + 1 }
fold(0) { acc, _ -> acc + 1 }
/**
/**
+2
View File
@@ -14,6 +14,8 @@
* limitations under the License.
*/
@file:Suppress("UNUSED_PARAMETER", "NOTHING_TO_INLINE")
package kotlin
/**
+1 -1
View File
@@ -26,7 +26,7 @@ public inline fun String.substring(startIndex: Int, endIndex: Int): String = asD
public inline fun String.concat(str: String): String = asDynamic().concat(str)
@kotlin.internal.InlineOnly
public inline fun String.match(regex: String): Array<String> = asDynamic().match(regex)
public inline fun String.match(regex: String): Array<String>? = asDynamic().match(regex)
//native public fun String.trim(): String
//TODO: String.replace to implement effective trimLeading and trimTrailing
+1 -1
View File
@@ -39,7 +39,7 @@ public fun String.endsWith(suffix: String, ignoreCase: Boolean = false): Boolean
public inline fun String.matches(regex: String): Boolean {
val result = this.match(regex)
return result != null && result.size > 0
return result != null && result.size != 0
}
public fun CharSequence.isBlank(): Boolean = length == 0 || (if (this is String) this else this.toString()).matches("^[\\s\\xA0]+$")
+1 -1
View File
@@ -24,7 +24,7 @@ public interface Appendable {
}
public class StringBuilder(content: String = "") : Appendable, CharSequence {
constructor(capacity: Int) : this() {}
constructor(@Suppress("UNUSED_PARAMETER") capacity: Int) : this() {}
constructor(content: CharSequence) : this(content.toString()) {}
@@ -1,3 +1,4 @@
@file: Suppress("DEPRECATION")
package jquery
import org.w3c.dom.Element
@@ -1,3 +1,4 @@
@file: Suppress("DEPRECATION")
package jquery.ui
+2 -2
View File
@@ -27,8 +27,8 @@ public external interface ItemArrayLike<out T> {
public fun <T> ItemArrayLike<T>.asList(): List<T> = object : AbstractList<T>() {
override val size: Int get() = this@asList.length
override fun get(index: Int): T = when {
index in 0..lastIndex -> this@asList.item(index) as T
override fun get(index: Int): T = when (index) {
in 0..lastIndex -> this@asList.item(index).unsafeCast<T>()
else -> throw IndexOutOfBoundsException("index $index is not in range [0..$lastIndex]")
}
}