I agree that this needs improvement, but I think other languages handle it poorly, and the right solution for Swift is to just get rid of the .self
. That way, you can use labels, and not have to fill in type placeholders.
E.g. given…
func f<T, U>(
goodLabel: T.Type = Int.self,
thingThatIsBestInBetween: some Any,
evenBetterLabel: U.Type = U.self
) -> (T.Type, U.Type) {
(T.self, U.self)
}
…
_ = f<_, Void>(thingThatIsBestInBetween: "thing")
is better than
_ = f(thingThatIsBestInBetween: "thing") as (_, Void.Type)
but
_ = f<_, Never>(thingThatIsBestInBetween: "thing")
is worse than
_ = f(thingThatIsBestInBetween: "thing", evenBetterLabel: Never)