From bffecea0a17dcf863c81bde595e5f73d98329692 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 4 Sep 2020 20:49:02 +0800 Subject: [PATCH] Fix generic types --- .../console/extension/AbstractExtensionPoint.kt | 14 ++++++-------- .../console/permission/PermissionService.kt | 17 ++++++++++++++++- frontend/mirai-console-pure/build.gradle.kts | 2 +- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/AbstractExtensionPoint.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/AbstractExtensionPoint.kt index be6b244ee..4a52ef01a 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/AbstractExtensionPoint.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/AbstractExtensionPoint.kt @@ -63,12 +63,12 @@ public open class ExtensionException : RuntimeException { public constructor(cause: Throwable?) : super(cause) } -internal inline fun AbstractExtensionPoint.withExtensions(block: T.() -> Unit) { +internal inline fun AbstractExtensionPoint.withExtensions(block: T.() -> Unit) { return withExtensions { _ -> block() } } @LowPriorityInOverloadResolution -internal inline fun AbstractExtensionPoint.withExtensions(block: T.(plugin: Plugin) -> Unit) { +internal inline fun AbstractExtensionPoint.withExtensions(block: T.(plugin: Plugin) -> Unit) { contract { callsInPlace(block) } @@ -81,7 +81,7 @@ internal inline fun AbstractExtensionPoint.withExtensions(block: T. } } -internal inline fun AbstractExtensionPoint.foldExtensions( +internal inline fun AbstractExtensionPoint.foldExtensions( initial: E, block: (acc: E, extension: T) -> E ): E { @@ -99,7 +99,7 @@ internal inline fun AbstractExtensionPoint.foldExtensions( return e } -internal fun AbstractExtensionPoint.throwExtensionException( +internal fun AbstractExtensionPoint.throwExtensionException( extension: T, plugin: Plugin, throwable: Throwable @@ -110,11 +110,9 @@ internal fun AbstractExtensionPoint.throwExtensionException( ) } -internal fun AbstractExtensionPoint - -internal inline fun AbstractExtensionPoint.useExtensions(block: (extension: T) -> Unit): Unit = +internal inline fun AbstractExtensionPoint.useExtensions(block: (extension: T) -> Unit): Unit = withExtensions(block) @LowPriorityInOverloadResolution -internal inline fun AbstractExtensionPoint.useExtensions(block: (extension: T, plugin: Plugin) -> Unit): Unit = +internal inline fun AbstractExtensionPoint.useExtensions(block: (extension: T, plugin: Plugin) -> Unit): Unit = withExtensions(block) \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt index 63b0b43f0..0d01df6b8 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt @@ -9,6 +9,7 @@ package net.mamoe.mirai.console.permission +import net.mamoe.mirai.console.extension.useExtensions import net.mamoe.mirai.console.extensions.PermissionServiceProvider import net.mamoe.mirai.console.util.ConsoleExperimentalAPI @@ -16,4 +17,18 @@ import net.mamoe.mirai.console.util.ConsoleExperimentalAPI * [PermissionServiceProvider] */ @ConsoleExperimentalAPI -public interface PermissionService \ No newline at end of file +public interface PermissionService { + + + public companion object : PermissionService { + private val instance by lazy { + PermissionServiceProvider.useExtensions { } + } + + } +} + +public interface proprietary + +@ConsoleExperimentalAPI +public interface Permission diff --git a/frontend/mirai-console-pure/build.gradle.kts b/frontend/mirai-console-pure/build.gradle.kts index aa7c2b6bc..9f9428196 100644 --- a/frontend/mirai-console-pure/build.gradle.kts +++ b/frontend/mirai-console-pure/build.gradle.kts @@ -11,7 +11,7 @@ kotlin { target.compilations.all { kotlinOptions { jvmTarget = "1.8" - freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=enable" + freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all" } }