Merge remote-tracking branch 'origin/master' into dependencies

This commit is contained in:
Karlatemp 2020-09-04 21:19:23 +08:00
commit 2ef4809d01
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8
4 changed files with 25 additions and 10 deletions

View File

@ -32,7 +32,7 @@ kotlin {
target.compilations.all {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=enable"
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
//useIR = true
}
}

View File

@ -22,7 +22,7 @@ import kotlin.internal.LowPriorityInOverloadResolution
import kotlin.reflect.KClass
@ConsoleExperimentalAPI
public open class AbstractExtensionPoint<T : Any>(
public open class AbstractExtensionPoint<T : Extension>(
@ConsoleExperimentalAPI
public val type: KClass<T>
) {
@ -63,12 +63,12 @@ public open class ExtensionException : RuntimeException {
public constructor(cause: Throwable?) : super(cause)
}
internal inline fun <T : Any> AbstractExtensionPoint<T>.withExtensions(block: T.() -> Unit) {
internal inline fun <T : Extension> AbstractExtensionPoint<out T>.withExtensions(block: T.() -> Unit) {
return withExtensions { _ -> block() }
}
@LowPriorityInOverloadResolution
internal inline fun <T : Any> AbstractExtensionPoint<T>.withExtensions(block: T.(plugin: Plugin) -> Unit) {
internal inline fun <T : Extension> AbstractExtensionPoint<out T>.withExtensions(block: T.(plugin: Plugin) -> Unit) {
contract {
callsInPlace(block)
}
@ -81,7 +81,7 @@ internal inline fun <T : Any> AbstractExtensionPoint<T>.withExtensions(block: T.
}
}
internal inline fun <T : Any, E> AbstractExtensionPoint<T>.foldExtensions(
internal inline fun <T : Extension, E> AbstractExtensionPoint<out T>.foldExtensions(
initial: E,
block: (acc: E, extension: T) -> E
): E {
@ -99,7 +99,7 @@ internal inline fun <T : Any, E> AbstractExtensionPoint<T>.foldExtensions(
return e
}
internal fun <T : Any> AbstractExtensionPoint<T>.throwExtensionException(
internal fun <T : Extension> AbstractExtensionPoint<out T>.throwExtensionException(
extension: T,
plugin: Plugin,
throwable: Throwable
@ -110,9 +110,9 @@ internal fun <T : Any> AbstractExtensionPoint<T>.throwExtensionException(
)
}
internal inline fun <T : Any> AbstractExtensionPoint<T>.useExtensions(block: (extension: T) -> Unit): Unit =
internal inline fun <T : Extension> AbstractExtensionPoint<T>.useExtensions(block: (extension: T) -> Unit): Unit =
withExtensions(block)
@LowPriorityInOverloadResolution
internal inline fun <T : Any> AbstractExtensionPoint<T>.useExtensions(block: (extension: T, plugin: Plugin) -> Unit): Unit =
internal inline fun <T : Extension> AbstractExtensionPoint<T>.useExtensions(block: (extension: T, plugin: Plugin) -> Unit): Unit =
withExtensions(block)

View File

@ -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
public interface PermissionService {
public companion object : PermissionService {
private val instance by lazy {
PermissionServiceProvider.useExtensions { }
}
}
}
public interface proprietary
@ConsoleExperimentalAPI
public interface Permission

View File

@ -11,7 +11,7 @@ kotlin {
target.compilations.all {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=enable"
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
}
}