为什么kotlin中不支持挂起运算符fun getValue?

为什么kotlin中不支持挂起运算符fun getValue?,kotlin,kotlin-coroutines,Kotlin,Kotlin Coroutines,为什么下面的签名会出现不受支持的[suspend operator“getValue”]编译错误 suspend operator fun getValue(thisRef: Any?, property: KProperty<*>): T suspend操作符fun getValue(thisRef:Any?,属性:KProperty):T 这是因为任何技术限制吗?getValue操作符用于实现val的getter,并且没有挂起val之类的东西——只有正常的val 一个susp

为什么下面的签名会出现
不受支持的[suspend operator“getValue”]
编译错误

suspend operator fun getValue(thisRef: Any?, property: KProperty<*>): T
suspend操作符fun getValue(thisRef:Any?,属性:KProperty):T

这是因为任何技术限制吗?

getValue操作符用于实现
val
的getter,并且没有
挂起val
之类的东西——只有正常的
val


一个
suspend fun
不能直接从一个普通函数调用,比如getter的实现——因此这个
getValue
不能用于它的预期目的。Kotlin警告您,在尝试创建
suspend操作符fun getValue

时出现编译错误,
getValue
操作符用于实现
val
的getter,而不存在
suspend val
这类东西——只有正常的
val

一个
suspend fun
不能直接从一个普通函数调用,比如getter的实现——因此这个
getValue
不能用于它的预期目的。Kotlin警告您,在尝试创建
挂起运算符fun getValue
时会出现编译错误