'Collect called methods into mocked object in Kotlin?

I would like to create a class B, which is "mocking" some other class A, i.e. having the same set of publuc methods, but doing something different with calls to these methods: instead of executing them, it should rememeber them in the list and execute egainst A at the desired moment. I wan't this not for testing purpose, but to create a type safe builder for A. The problem is that constructor of A requires some obligatory arguments, so usully it is called in the beginning. I would collect all calls in builder and then would call constructor at the end of builder.

Is it possible with Kotlin without manually rewriting delegates of all methods of A?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source