JvmSuppressWildcards: The secret sauce to your sandwich-style generics

Photo: amirali mirhashemian from Unsplash

If generic types are exposed in Kotlin API, consider @JvmSuppressWildcards so that your Java consumer can compile successfully.

Kotlin generics are different from (in my opinion, smarter than) Java generics. Kotlin generics has declaration-site variance and type projections, which are officially documented here. Generics is a gigantic topic…