I assure you I fully understand what your idea is (or at least, nothing about your example changes my understanding of your idea). What I don't understand is
- What problem you're solving that balances the complexity cost of having nonuniform rules? You say “makes users less likely to write extensions for all overloads when they don't mean to,” but “writing extensions that apply to all concretizations when they don't mean to” is a problem people can have in Swift today, and we don't feel the need to add any special protections against it.
- Why you think that a special rule for full specializations that doesn't apply to partial specializations makes sense. I can easily write a partial specialization that effectively only applies to one concretization of the class template.
I also think there are a couple of holes in the way you're thinking about this:
-
constraints like
where T != Void
are unlikely to ever be allowed in Swift, because they are an anti-pattern and create provable type-checking complexity explosion (with NOT and conjunctions you can create disjunctions) in the implementation. -
The
h
's you've written don't actually touch the cases where checking can only happen in phase 2. Try this:extension X: DefaultConstructible {} // just for completeness func h<T>(_: T.Type) { g(X<T>()) } // Must pass type checking in phase 1 h(Void.self) // Must fail type checking in phase 2