Why can't I use @PublishedApi for typealias?
In my current project I have a public interface for different requests
interface Query<T>
and an internal implementation for this interface. Since I have built-in functions for making different requests, I need to use @PublishedApi
for this class
@PublishedApi
internal class QueryImpl<T> : Query<T>
Now, for convenience, I want to define some type aliases for different types of queries.
typealias MatchQuery = Query<MatchQueryProperties>
this works very well for this public interface, but I need to create one instance of it in my public inline function
inline fun match(init: MatchQuery.() -> Unit) {
// It would look nicer if I could use MatchQueryImpl().init()
QueryImpl<MatchQueryProperties>().init()
}
But instead of writing QueryImpl<PropertiesType>
for each request type, I want to use internal types for implementation too.
// fails because it needs to be internal
typealias MatchQueryImpl = QueryImpl<MatchQueryProperties>
// can't be used in public inline functions
internal typealias MatchQueryImpl = QueryImpl<MatchQueryProperties>
// annotation can't be used on typealias
@PublishedApi internal typealias MatchQueryImpl = QueryImpl<MatchQueryProperties>
So my questions are:
Can I use it in some way @PublishedApi internal typealias
?
If not, why can't I use it?
Is there another way to archive what I want?
source to share