diff --git a/mirai-core-utils/src/commonMain/kotlin/LateinitMutableProperty.kt b/mirai-core-utils/src/commonMain/kotlin/LateinitMutableProperty.kt index 3013018ba..e3a7bc0bc 100644 --- a/mirai-core-utils/src/commonMain/kotlin/LateinitMutableProperty.kt +++ b/mirai-core-utils/src/commonMain/kotlin/LateinitMutableProperty.kt @@ -36,9 +36,12 @@ private class LateinitMutableProperty( val initializer = initializer if (initializer != null && this.value.value === UNINITIALIZED) { val value = initializer() - this.value.compareAndSet(UNINITIALIZED, value) // setValue prevails this.initializer = null - value + this.value.compareAndSet(UNINITIALIZED, value) // setValue prevails + this.value.value.let { + assert(it !== UNINITIALIZED) + return it as T + } } else this.value.value as T } else -> v as T