inspektAndProxy

fun <T : Any> inspektAndProxy(@ReferenceLiteral(mustBeInterface = true) toImplement: KClass<T>, @StringLiteral name: String? = null): ProxyableInspektion<T>(source)

Create an Inspektion and a proxy object factory, for proxies that implements T and responds to all method or accessor calls using the handler passed to the factory. toImplement must be a class reference literal of an interface.

A call to this method is transformed into an anonymous object instance by the compiler plugin. All the arguments are calculated at compilation time.

Because of this, uses of this function can potentially add a significant amount of binary size. This is based on the number of appearances of inspektAndProxy() in your code, not how many times it is invoked. Calling the factory does not add overhead, only the inspektAndProxy call.

Parameters

name

the name to use for the proxy class. Must be a constant value.

See also

Throws

if it was not intrinsified by the Inspekt compiler plugin.