Fix warnings

This commit is contained in:
Him188 2020-03-05 21:36:46 +08:00
parent b0abd0df28
commit 3b16f0a226
4 changed files with 14 additions and 5 deletions

View File

@ -191,12 +191,12 @@ private class JceInput(
/**
* 跳过 [JceHead] 和对应的数据值, 直到找到 [tag], 否则抛出异常
*/
inline fun <R> skipToTagAndUseIfPossibleOrFail(
inline fun <R : Any> skipToTagAndUseIfPossibleOrFail(
tag: Int,
crossinline message: () -> String = { "tag not found: $tag" },
crossinline block: (JceHead) -> R
): R {
return checkNotNull(skipToTagAndUseIfPossibleOrNull(tag, block), message)
return checkNotNull<R>(skipToTagAndUseIfPossibleOrNull(tag, block), message)
}
tailrec fun skipToHeadOrNull(tag: Int): JceHead? {

View File

@ -30,8 +30,9 @@ import java.net.URL
/**
* 读取 [BufferedImage] 的属性, 然后构造 [ExternalImage]
* 读取 [Bitmap] 的属性, 然后构造 [ExternalImage]
*/
@Suppress("UNUSED_PARAMETER")
@Throws(IOException::class)
fun Bitmap.toExternalImage(formatName: String = "gif"): Nothing {
TODO()

View File

@ -7,6 +7,8 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@file:Suppress("unused")
package net.mamoe.mirai.utils
import android.annotation.SuppressLint
@ -18,6 +20,7 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import kotlinx.serialization.UnstableDefault
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import java.io.File
/**
@ -27,14 +30,17 @@ import java.io.File
fun File.loadAsDeviceInfo(context: Context): DeviceInfo {
if (!this.exists() || this.length() == 0L) {
return SystemDeviceInfo(context).also {
this.writeText(Json.plain.stringify(SystemDeviceInfo.serializer(), it))
this.writeText(JSON.stringify(SystemDeviceInfo.serializer(), it))
}
}
return Json.nonstrict.parse(DeviceInfoData.serializer(), this.readText()).also {
return JSON.parse(DeviceInfoData.serializer(), this.readText()).also {
it.context = context
}
}
@OptIn(UnstableDefault::class)
private val JSON = Json(JsonConfiguration.Default)
/**
* 部分引用指向 [Build].
* 部分需要权限, 若无权限则会使用默认值.

View File

@ -15,6 +15,7 @@ import io.ktor.utils.io.ByteReadChannel
import io.ktor.utils.io.core.ByteReadPacket
import io.ktor.utils.io.core.Input
import kotlinx.io.InputStream
import kotlinx.serialization.InternalSerializationApi
import net.mamoe.mirai.contact.Contact
import net.mamoe.mirai.contact.Group
import net.mamoe.mirai.contact.QQ
@ -69,6 +70,7 @@ class ExternalImage private constructor(
filename: String
) : this(width, height, md5, imageFormat, input as Any, input.remaining, filename)
@OptIn(InternalSerializationApi::class)
constructor(
width: Int,
height: Int,