How to exploit kotlin's inline benefits when function has an object with a lambda parameter
How to exploit kotlin's inline benefits when function has an object with a lambda parameter lets say I have a data class like so private data class StubModel<T>( val invocation: ItemsFactory.() -> T?, val returnValue: T ) and I have a function like so private fun <T> stubIt(stubs: List<StubModel<T>>) { for (stub in stubs) { whenever(stub.invocation()).thenReturn(stub.returnValue) } } now when I try to the inline the stubIt function I dont get any performance benefits (i.e the lambda parameter in the StubModel is not inlined which is why I want the power of inline), how do I get kotlin compiler to inline the lambda parameter in the model class at the call site? stubIt StubModel 1 Answer 1 This is not possible. As a property of your StubModel , the invocation needs to be an object instance and stored as such. This is just, what inline ...