asContribution

inline fun <T : Any> Any.asContribution(): T(source)

Casts this graph instance as the expected contribution type T. This is useful for cases where you want to upcast a merged graph to an expected contribution type.

This is validated at compile-time to prevent unexpected casts.

This is not necessary if you enable IDE support.

NOTE: This is only applicable to DependencyGraph-annotated types. ContributesGraphExtension-annotated types cannot be validated at compile-time with this function as their generated class is definitionally contextual and the compiler cannot infer that from callsites of this function alone.

See also