fun (() -> T).withIdentity(vararg deps: Any?): () -> T = WrappedFunction0( this, deps.contentHashCode() ) private class WrappedFunction0( private val function: () -> T, private val identity: Int ) : () -> T { override fun invoke() = function() override fun equals(other: Any?) = other is WrappedFunction0<*> && identity == other.identity override fun hashCode() = identity }