I have shortened the names of some frequently-used foreign functions (that I don't control) with "aliases", based on advice I received in an earlier question. This has worked nicely for extension functions; however, I have a few top-level functions I'd like to alias as well. For a simplified example, consider the generateSequence
function. I want to be able to do this:
// DOES NOT COMPILE
inline val <T:Any> seq:(()->T?)->Sequence<T> get() = ::generateSequence
...but I can't because the generic must be used in the receiver type, as explained well in this answer. Is there any other way to create an alias for a top-level function (requiring generics) which preserves the inline?
EDIT: I tried using Any?
and star projection right after posting the question, but I still don't think it's a good answer:
inline val seq:(()->Any?)->Sequence<*> get() = ::generateSequence
This seems boptimalsu because it compromises type-checking on the Sequence's element type, correct? Other answers/thoughts as to what could work?