I’m getting ReenteringLazyValueComputationException when I try to compile the following piece of code (an optimized method for a function that gets called very often). No idea why I would get that - code looks alright?
class FailedValidationResult(
details: Collection<FailedValidationResult> = emptySet(),
private val useDetailsOnly: Boolean = false
) {
val details = details.mapInto { element, output ->
if (element.useDetailsOnly)
output.addAll(element.details)
else
output.add(element)
}
}
private inline fun <E> Collection<E>.mapInto(
action: (element: E, output: MutableCollection<E>) -> Unit
): Collection<E> {
val result: MutableCollection<E> = ArrayList(this.size)
this.forEach {
action(it, result)
}
return result
}