SE-0299 Extending Static Member Lookup in Generic Contexts

Sounds secret enough to be practically usable. Somebody will probably run into a naming collision, but I bet that would have been a confusing name anyway.


All this said, I do think that being able to discover these types outside of the context of generic methods would be helpful. Their initializers represent the same idea as enumeration cases (without exhaustibility).

Chris's idea here is good, but it, along with the original StaticMember, represents a larger scope than what we're specifically dealing with, which is an alternate way of accessing initializers.

You can almost represent what's needed, right now, with typealiases:

public enum TabViewStyleCase {
  public typealias `default` = DefaultTabViewStyle

  #if !os(macOS)
  public typealias page = PageTabViewStyle
  #endif
}

public extension TabViewStyle {
  typealias Case = TabViewStyleCase
}
.tabViewStyle(TabViewStyle.Case.default())
.tabViewStyle(TabViewStyle.Case.page())
.tabViewStyle(TabViewStyle.Case.page(indexDisplayMode: .always))

Just add compiler magic to make it so we can drop

  1. the type name, when using some specific protocol-nested typealias (Case, here)
  2. the parentheses when not using parameters

And ideally, you'd then do that code completion hiding so that concrete types don't appear to have access to the nested typealias.