2017-12-29 91 views
2

kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Introspecting local functions, lambdas, anonymous functions and local variables is not yet fully supported in Kotlin reflection코 틀린/안드로이드 - 람다

이 예외와 데이터 클래스에 KotlinReflectionInternalError는 데이터 클래스의 toString()에서 온다.

데이터 클래스에는 람다가 포함되어 있습니다.

내 환경에서는 재생산 할 수 없습니다.

람다를 제외하려면 toString()을 무시해야합니까? 또는 람다는 데이터 클래스에서 전혀 허용되지 않습니까? 오류를 생산

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) 
+0

'내 환경에서는 재생할 수 없습니다.'- 어떻게해야합니까? – voddan

+1

충돌 보고서를 통해 확인하세요. –

답변

2

은 코 틀린 람다의 버그처럼 보인다.

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

I 조언 당신이 youtrack.jetbrains.com/issues/KT에 문제를 게시하고 팀이 그것에 대해 말하는 것을 참조 :

이 코드는 예외를 재현하기에 충분하다.

+0

귀하의 환경은 어떻습니까? 그것은 내'Kotlin 1.1.51 (JRE 1.8.0_144-b01)' –

+0

https://try.kotlinlang.org 1.2.10 JVM – voddan

+0

에 잘 작동합니다. 그리고'System.getProperty ("java.version")'은'1.8.0_45'를 반환합니다. 그래서 자바 버전의 문제가 아닌 것 같습니다. –