From 52f5008379841dafe66680878c51ac853aa2ca06 Mon Sep 17 00:00:00 2001 From: Him188 Date: Tue, 19 May 2020 16:08:25 +0800 Subject: [PATCH] Fix compilation --- .../mirai/console/codegen/ValueImplCodegen.kt | 7 +- backend/mirai-console/build.gradle.kts | 2 +- .../mamoe/mirai/console/setting/ValueImpl.kt | 40 +++--- .../mamoe/mirai/console/setting/_ValueImpl.kt | 127 ++++++++++-------- 4 files changed, 99 insertions(+), 77 deletions(-) diff --git a/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValueImplCodegen.kt b/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValueImplCodegen.kt index 0401e5093..a054f8857 100644 --- a/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValueImplCodegen.kt +++ b/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValueImplCodegen.kt @@ -108,7 +108,8 @@ fun genAllValueImpl(): String = buildString { ): Mutable${number}${collectionName}Value { var internalValue: Mutable${collectionName}<${number}> = default - return object : Mutable${number}${collectionName}Value(), Mutable${collectionName}<${number}> by dynamicMutable${collectionName}({ internalValue }) { + val delegt = dynamicMutable${collectionName}{ internalValue } + return object : Mutable${number}${collectionName}Value(), Mutable${collectionName}<${number}> by delegt { override var value: Mutable${collectionName}<${number}> get() = internalValue set(new) { @@ -118,7 +119,7 @@ fun genAllValueImpl(): String = buildString { } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = ${collectionName}Serializer(${number}.serializer()) @@ -126,7 +127,7 @@ fun genAllValueImpl(): String = buildString { override fun deserialize(decoder: Decoder): Mutable${collectionName}<${number}> { return delegate.deserialize(decoder).toMutable${collectionName}().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } diff --git a/backend/mirai-console/build.gradle.kts b/backend/mirai-console/build.gradle.kts index 60572b5fd..bf46b81c7 100644 --- a/backend/mirai-console/build.gradle.kts +++ b/backend/mirai-console/build.gradle.kts @@ -32,7 +32,7 @@ dependencies { compileAndRuntime("net.mamoe:mirai-core:${Versions.Mirai.core}") compileAndRuntime(kotlin("stdlib")) - api("net.mamoe.yamlkt:yamlkt:0.2.0") + api("net.mamoe.yamlkt:yamlkt:0.3.0") api("org.jsoup:jsoup:1.12.1") diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/ValueImpl.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/ValueImpl.kt index 0331ad96e..10660113f 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/ValueImpl.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/ValueImpl.kt @@ -53,7 +53,10 @@ internal fun Setting.valueImpl( internalValue.shadowMap(transform = { it.value }, transformBack = { valueMapper(it) }) var shadowed: MutableList = updateShadow() - return object : MutableListValue(), MutableList by dynamicMutableList({ shadowed }) { + + + val delegt = dynamicMutableList { shadowed } + return object : MutableListValue(), MutableList by delegt { override var value: MutableList> get() = internalValue set(new) { @@ -86,7 +89,8 @@ internal fun Setting.valueImpl( ): MutableSettingListValue { var internalValue: MutableList = default - return object : MutableSettingListValue(), MutableList by dynamicMutableList({ internalValue }) { + val delegt = dynamicMutableList { internalValue } + return object : MutableSettingListValue(), MutableList by delegt { override var value: MutableList get() = internalValue set(new) { @@ -118,7 +122,8 @@ internal fun Setting.valueImpl( ): SettingListValue { var internalValue: List = default - return object : SettingListValue(), List by dynamicList({ internalValue }) { + val delegt = dynamicList { internalValue } + return object : SettingListValue(), List by delegt { override var value: List get() = internalValue set(new) { @@ -150,7 +155,8 @@ internal fun Setting.valueImpl( ): SettingSetValue { var internalValue: Set = default - return object : SettingSetValue(), Set by dynamicSet({ internalValue }) { + val delegt = dynamicSet { internalValue } + return object : SettingSetValue(), Set by delegt { override var value: Set get() = internalValue set(new) { @@ -182,7 +188,8 @@ internal fun Setting.valueImpl( ): MutableSettingSetValue { var internalValue: MutableSet = default - return object : MutableSettingSetValue(), MutableSet by dynamicMutableSet({ internalValue }) { + val delegt = dynamicMutableSet { internalValue } + return object : MutableSettingSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue set(new) { @@ -247,7 +254,9 @@ internal fun Setting.valueImpl( internalValue.shadowMap(transform = { it.value }, transformBack = { valueMapper(it) }) var shadowed: MutableSet = updateShadow() - return object : MutableSetValue(), MutableSet by dynamicMutableSet({ shadowed }) { + + val delegt = dynamicMutableSet { shadowed } + return object : MutableSetValue(), MutableSet by delegt { override var value: MutableSet> get() = internalValue set(new) { @@ -293,20 +302,15 @@ internal fun Setting.valueImpl(default: T, clazz: KClass): Valu } return object : DynamicReferenceValue() { override var value: T = default - override val serializer: KSerializer - get() = object : KSerializer { - override val descriptor: SerialDescriptor - get() = YamlDynamicSerializer.descriptor + override val serializer: KSerializer = object : KSerializer { + override val descriptor: SerialDescriptor + get() = YamlDynamicSerializer.descriptor - override fun deserialize(decoder: Decoder): T { - return YamlDynamicSerializer.deserialize(decoder).smartCastPrimitive(clazz) - } + override fun deserialize(decoder: Decoder): T = + YamlDynamicSerializer.deserialize(decoder).smartCastPrimitive(clazz) - @OptIn(ImplicitReflectionSerializer::class) - override fun serialize(encoder: Encoder, value: T) { - YamlDynamicSerializer.serialize(encoder, value) - } - } + override fun serialize(encoder: Encoder, value: T) = YamlDynamicSerializer.serialize(encoder, value) + } } } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/_ValueImpl.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/_ValueImpl.kt index 17ce4184b..8382b8532 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/_ValueImpl.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/_ValueImpl.kt @@ -7,7 +7,6 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ - package net.mamoe.mirai.console.setting import kotlinx.serialization.Decoder @@ -690,7 +689,8 @@ internal fun Setting.valueImpl( ): MutableIntListValue { var internalValue: MutableList = default - return object : MutableIntListValue(), MutableList by dynamicMutableList({ internalValue }) { + val delegt = dynamicMutableList { internalValue } + return object : MutableIntListValue(), MutableList by delegt { override var value: MutableList get() = internalValue set(new) { @@ -700,7 +700,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Int.serializer()) @@ -708,7 +708,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableList { return delegate.deserialize(decoder).toMutableList().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -725,7 +725,8 @@ internal fun Setting.valueImpl( ): MutableShortListValue { var internalValue: MutableList = default - return object : MutableShortListValue(), MutableList by dynamicMutableList({ internalValue }) { + val delegt = dynamicMutableList { internalValue } + return object : MutableShortListValue(), MutableList by delegt { override var value: MutableList get() = internalValue set(new) { @@ -735,7 +736,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Short.serializer()) @@ -743,7 +744,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableList { return delegate.deserialize(decoder).toMutableList().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -760,7 +761,8 @@ internal fun Setting.valueImpl( ): MutableByteListValue { var internalValue: MutableList = default - return object : MutableByteListValue(), MutableList by dynamicMutableList({ internalValue }) { + val delegt = dynamicMutableList { internalValue } + return object : MutableByteListValue(), MutableList by delegt { override var value: MutableList get() = internalValue set(new) { @@ -770,7 +772,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Byte.serializer()) @@ -778,7 +780,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableList { return delegate.deserialize(decoder).toMutableList().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -795,7 +797,8 @@ internal fun Setting.valueImpl( ): MutableLongListValue { var internalValue: MutableList = default - return object : MutableLongListValue(), MutableList by dynamicMutableList({ internalValue }) { + val delegt = dynamicMutableList { internalValue } + return object : MutableLongListValue(), MutableList by delegt { override var value: MutableList get() = internalValue set(new) { @@ -805,7 +808,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Long.serializer()) @@ -813,7 +816,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableList { return delegate.deserialize(decoder).toMutableList().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -830,7 +833,8 @@ internal fun Setting.valueImpl( ): MutableFloatListValue { var internalValue: MutableList = default - return object : MutableFloatListValue(), MutableList by dynamicMutableList({ internalValue }) { + val delegt = dynamicMutableList { internalValue } + return object : MutableFloatListValue(), MutableList by delegt { override var value: MutableList get() = internalValue set(new) { @@ -840,7 +844,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Float.serializer()) @@ -848,7 +852,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableList { return delegate.deserialize(decoder).toMutableList().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -865,7 +869,8 @@ internal fun Setting.valueImpl( ): MutableDoubleListValue { var internalValue: MutableList = default - return object : MutableDoubleListValue(), MutableList by dynamicMutableList({ internalValue }) { + val delegt = dynamicMutableList { internalValue } + return object : MutableDoubleListValue(), MutableList by delegt { override var value: MutableList get() = internalValue set(new) { @@ -875,7 +880,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Double.serializer()) @@ -883,7 +888,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableList { return delegate.deserialize(decoder).toMutableList().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -900,7 +905,8 @@ internal fun Setting.valueImpl( ): MutableBooleanListValue { var internalValue: MutableList = default - return object : MutableBooleanListValue(), MutableList by dynamicMutableList({ internalValue }) { + val delegt = dynamicMutableList { internalValue } + return object : MutableBooleanListValue(), MutableList by delegt { override var value: MutableList get() = internalValue set(new) { @@ -910,7 +916,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Boolean.serializer()) @@ -918,7 +924,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableList { return delegate.deserialize(decoder).toMutableList().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -935,7 +941,8 @@ internal fun Setting.valueImpl( ): MutableCharListValue { var internalValue: MutableList = default - return object : MutableCharListValue(), MutableList by dynamicMutableList({ internalValue }) { + val delegt = dynamicMutableList { internalValue } + return object : MutableCharListValue(), MutableList by delegt { override var value: MutableList get() = internalValue set(new) { @@ -945,7 +952,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Char.serializer()) @@ -953,7 +960,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableList { return delegate.deserialize(decoder).toMutableList().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -970,7 +977,8 @@ internal fun Setting.valueImpl( ): MutableStringListValue { var internalValue: MutableList = default - return object : MutableStringListValue(), MutableList by dynamicMutableList({ internalValue }) { + val delegt = dynamicMutableList { internalValue } + return object : MutableStringListValue(), MutableList by delegt { override var value: MutableList get() = internalValue set(new) { @@ -980,7 +988,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(String.serializer()) @@ -988,7 +996,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableList { return delegate.deserialize(decoder).toMutableList().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -1005,7 +1013,8 @@ internal fun Setting.valueImpl( ): MutableIntSetValue { var internalValue: MutableSet = default - return object : MutableIntSetValue(), MutableSet by dynamicMutableSet({ internalValue }) { + val delegt = dynamicMutableSet { internalValue } + return object : MutableIntSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue set(new) { @@ -1015,7 +1024,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Int.serializer()) @@ -1023,7 +1032,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableSet { return delegate.deserialize(decoder).toMutableSet().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -1040,7 +1049,8 @@ internal fun Setting.valueImpl( ): MutableShortSetValue { var internalValue: MutableSet = default - return object : MutableShortSetValue(), MutableSet by dynamicMutableSet({ internalValue }) { + val delegt = dynamicMutableSet { internalValue } + return object : MutableShortSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue set(new) { @@ -1050,7 +1060,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Short.serializer()) @@ -1058,7 +1068,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableSet { return delegate.deserialize(decoder).toMutableSet().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -1075,7 +1085,8 @@ internal fun Setting.valueImpl( ): MutableByteSetValue { var internalValue: MutableSet = default - return object : MutableByteSetValue(), MutableSet by dynamicMutableSet({ internalValue }) { + val delegt = dynamicMutableSet { internalValue } + return object : MutableByteSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue set(new) { @@ -1085,7 +1096,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Byte.serializer()) @@ -1093,7 +1104,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableSet { return delegate.deserialize(decoder).toMutableSet().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -1110,7 +1121,8 @@ internal fun Setting.valueImpl( ): MutableLongSetValue { var internalValue: MutableSet = default - return object : MutableLongSetValue(), MutableSet by dynamicMutableSet({ internalValue }) { + val delegt = dynamicMutableSet { internalValue } + return object : MutableLongSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue set(new) { @@ -1120,7 +1132,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Long.serializer()) @@ -1128,7 +1140,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableSet { return delegate.deserialize(decoder).toMutableSet().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -1145,7 +1157,8 @@ internal fun Setting.valueImpl( ): MutableFloatSetValue { var internalValue: MutableSet = default - return object : MutableFloatSetValue(), MutableSet by dynamicMutableSet({ internalValue }) { + val delegt = dynamicMutableSet { internalValue } + return object : MutableFloatSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue set(new) { @@ -1155,7 +1168,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Float.serializer()) @@ -1163,7 +1176,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableSet { return delegate.deserialize(decoder).toMutableSet().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -1180,7 +1193,8 @@ internal fun Setting.valueImpl( ): MutableDoubleSetValue { var internalValue: MutableSet = default - return object : MutableDoubleSetValue(), MutableSet by dynamicMutableSet({ internalValue }) { + val delegt = dynamicMutableSet { internalValue } + return object : MutableDoubleSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue set(new) { @@ -1190,7 +1204,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Double.serializer()) @@ -1198,7 +1212,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableSet { return delegate.deserialize(decoder).toMutableSet().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -1215,7 +1229,8 @@ internal fun Setting.valueImpl( ): MutableBooleanSetValue { var internalValue: MutableSet = default - return object : MutableBooleanSetValue(), MutableSet by dynamicMutableSet({ internalValue }) { + val delegt = dynamicMutableSet { internalValue } + return object : MutableBooleanSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue set(new) { @@ -1225,7 +1240,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Boolean.serializer()) @@ -1233,7 +1248,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableSet { return delegate.deserialize(decoder).toMutableSet().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -1250,7 +1265,8 @@ internal fun Setting.valueImpl( ): MutableCharSetValue { var internalValue: MutableSet = default - return object : MutableCharSetValue(), MutableSet by dynamicMutableSet({ internalValue }) { + val delegt = dynamicMutableSet { internalValue } + return object : MutableCharSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue set(new) { @@ -1260,7 +1276,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Char.serializer()) @@ -1268,7 +1284,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableSet { return delegate.deserialize(decoder).toMutableSet().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } } @@ -1285,7 +1301,8 @@ internal fun Setting.valueImpl( ): MutableStringSetValue { var internalValue: MutableSet = default - return object : MutableStringSetValue(), MutableSet by dynamicMutableSet({ internalValue }) { + val delegt = dynamicMutableSet { internalValue } + return object : MutableStringSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue set(new) { @@ -1295,7 +1312,7 @@ internal fun Setting.valueImpl( } } - private inline val `this` get() = this + private val outerThis get() = this override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(String.serializer()) @@ -1303,7 +1320,7 @@ internal fun Setting.valueImpl( override fun deserialize(decoder: Decoder): MutableSet { return delegate.deserialize(decoder).toMutableSet().observable { - onElementChanged(`this`) + onElementChanged(outerThis) } }