Bug in `where`?

This subtyping relation doesn’t work well with Java-compatibility for instance and can be a bit buggy at times. The Kotlin compiler allows it for the stdlib because it is useful in a minority of scenarioes. If you would like to use it yourself, just suppress the error :slight_smile: :

@Suppress("BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER")
inline fun <C, R> C.ifEmptyOrBlank(defaultValue: () -> R): R where C : CharSequence, C : R =
    if (isEmpty() || isBlank()) defaultValue() else this
4 Likes