Fix build

This commit is contained in:
Him188 2020-05-24 14:56:06 +08:00
parent 8ea0c538a0
commit 1cf35b8554
2 changed files with 23 additions and 21 deletions

View File

@ -65,8 +65,10 @@ object JarPluginLoader : AbstractFilePluginLoader<JvmPlugin, JvmPluginDescriptio
} }
} }
@Suppress("RemoveExplicitTypeArguments") // until Kotlin 1.4 NI
@Throws(PluginLoadException::class) @Throws(PluginLoadException::class)
override fun load(description: JvmPluginDescription): JvmPlugin = description.runCatching { override fun load(description: JvmPluginDescription): JvmPlugin =
description.runCatching<JvmPluginDescription, JvmPlugin> {
ensureActive() ensureActive()
val main = classLoader.loadPluginMainClassByJarFile(name, mainClassName, file).kotlin.run { val main = classLoader.loadPluginMainClassByJarFile(name, mainClassName, file).kotlin.run {
objectInstance objectInstance
@ -84,7 +86,7 @@ object JarPluginLoader : AbstractFilePluginLoader<JvmPlugin, JvmPluginDescriptio
main.internalOnLoad() main.internalOnLoad()
} else main.onLoad() } else main.onLoad()
main main
}.getOrElse { }.getOrElse<JvmPlugin, JvmPlugin> {
throw PluginLoadException("Exception while loading ${description.name}", it) throw PluginLoadException("Exception while loading ${description.name}", it)
} }

View File

@ -12,13 +12,13 @@
package net.mamoe.mirai.console.command package net.mamoe.mirai.console.command
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.console.plugins.PluginBase import net.mamoe.mirai.console.plugins.builtin.KotlinPlugin
import net.mamoe.mirai.message.data.* import net.mamoe.mirai.message.data.*
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
val plugin: PluginBase = object : PluginBase() { val plugin: KotlinPlugin = object : KotlinPlugin() {
} }