Allow bounds on typealias type parameters

Would it be possible to allow bounds on typealias type parameters?

typealias UseCase<T : Result> = (String) -> T

I need this for a generic functional type with bounded type parameter, which should be passed to non-generic classes (with concrete type argument):

data class SystemData : Result

class Presenter(val useCase: UseCase<SystemData>)

But sometimes I don’t know the exact result type so I will use a star projection:

class Presenter(val useCase: UseCase<*>)

And I still want to be sure that UseCase will return a Result.

1 Like