Exception Kotlin/Android–;具有lambda的数据类中的KotlinReflectionInternalError

Exception Kotlin/Android–;具有lambda的数据类中的KotlinReflectionInternalError,exception,reflection,lambda,kotlin,kotlinx.coroutines,Exception,Reflection,Lambda,Kotlin,Kotlinx.coroutines,kotlin.reflect.jvm.internal.KotlinReflectionInternalError: 内省局部函数、lambda、匿名函数和局部函数 Kotlin反射中尚未完全支持变量 此异常来自数据类的toString() 数据类包含一个lambda 我无法在我的环境中复制它 是否需要重写toString()以排除lambda?或者根本不允许在数据类中使用lambda data class PersistJob( private val id: Int,

kotlin.reflect.jvm.internal.KotlinReflectionInternalError: 内省局部函数、lambda、匿名函数和局部函数 Kotlin反射中尚未完全支持变量

此异常来自数据类的
toString()

数据类包含一个lambda

我无法在我的环境中复制它

是否需要重写
toString()
以排除lambda?或者根本不允许在数据类中使用lambda

data class PersistJob(
        private val id: Int,
        private val delay: Long = 10_000L,
        private val maxDelay: Long = 60_000L,
        private val iteration: Int = 0,
        private val block: suspend (Int) -> Boolean) {

    fun getDelay() = minOf(delay, maxDelay)
    fun withDelayIncreased() = copy(
            delay = minOf(delay * 2, maxDelay),
            iteration = iteration + 1)

    suspend fun execute() = block(iteration)
}
产生错误的行:

val job: PersistJob = ...
log.debug("start job id($id): $job")`// job.toString()
堆栈跟踪:

at kotlin.reflect.jvm.internal.EmptyContainerForLocal.fail(SourceFile:41)
at kotlin.reflect.jvm.internal.EmptyContainerForLocal.getFunctions(SourceFile:37)
at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.findFunctionDescriptor(SourceFile:145)
at kotlin.reflect.jvm.internal.KFunctionImpl$descriptor$2.invoke(SourceFile:54)
at kotlin.reflect.jvm.internal.KFunctionImpl$descriptor$2.invoke(SourceFile:34)
at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke(SourceFile:93)
at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(SourceFile:32)
at kotlin.reflect.jvm.internal.KFunctionImpl.getDescriptor(SourceFile)
at kotlin.reflect.jvm.internal.ReflectionFactoryImpl.renderLambdaToString(SourceFile:59)
at kotlin.jvm.internal.Reflection.renderLambdaToString(SourceFile:80)
at kotlin.jvm.internal.Lambda.toString(SourceFile:22)
at java.lang.String.valueOf(String.java:2683)
at java.lang.StringBuilder.append(StringBuilder.java:129)

它看起来像科特林·兰博达斯的一只虫子

此代码足以重现异常:

 ({i: Int -> true}).toString()

我建议你在youtrack.jetbrains.com/issues/KT上发布一个问题,看看团队对此有何评论。

我无法在我的环境中重现它。
-为什么?通过崩溃报告。我相信当android设备低于6.0时,会出现此错误。在6.0及以上版本的设备上使用相同的问题应用程序,但在5.0版本中没有。我相信这是Kotlin的一个bug你的环境是什么?它在我的
Kotlin 1.1.51版(JRE 1.8.0_144-b01)上运行良好
是的。和
System.getProperty(“java.version”)
返回
1.8.0\u 45
。所以这似乎不是Java版本的问题。