Bug in 1.5 compiler

I just upgraded to 1.5 and am running into this problem. Given this code:

class AtMostNExceptionHandling(
    private val maximumNumberOfExceptionsToHandleAfterLastSuccess: Int,
    workBlock: Runnable,
    exceptionHandlingBlock: Consumer<Exception>,
    successfulAgainHandler: () -> Unit = {}
) {
    ...
}

val workBlock = outgoingKafkaQueueProcessor::processAllQueuedMessages
val exceptionHandlerBlock = { exception: Exception ->
    ...
}
val atMostNExceptionHandling = AtMostNExceptionHandling(
    3,
    workBlock, // Line 21
    exceptionHandlerBlock,
    {
        ...
    }
)

I get the following exception at runtime:

Exception in thread "Thread-11" java.lang.NoSuchMethodError:
    kotlin.reflect.KFunction.invoke()Ljava/lang/Object;
    at com.maqqie.planning.core.kafka_outgoing.internal.queue_processor.
        OutgoingKafkaQueueWorkProcessingAvailabilityQueueTrigger.run$lambda-0
        (OutgoingKafkaQueueWorkProcessingAvailabilityQueueTrigger.kt:21)

When I inline workBlock I do not get an exception:

val atMostNExceptionHandling = AtMostNExceptionHandling(
    3,
    outgoingKafkaQueueProcessor::processAllQueuedMessages,
    exceptionHandlerBlock,
    {
        ...
    }
)

Bugs are better reported directly to https://youtrack.jetbrains.com/issues/KT.

Looks like someone else found it too. The fix seems scheduled for 1.5.30, which won’t be here soon I guess. But there is a workaround: https://youtrack.jetbrains.com/issue/KT-46512

You should comment on the problem and add “like”. It improves chances for fix to be back-ported to, say 1.5.20.

I misread. I missed the target verions, and only saw fix in builds: 1.5.30-dev-384. It looks like it will be in 1.5.10.