[Pitch] Type Wrappers

S in your example represents $Storage not the wrapped type and there is no synthesis of Hashable, Equatable etc. yet as I mentioned in my previous comment.

Applying type wrapper to a protocol does two things:

  • Injects associatedtype $Storage and var $_storage: OnlyAppliesToHashable<Self.$Storage>
  • Allows it infer @OnlyAppliesToHashable from conformance to NotExplicitlyHashable

Yes, there are no limitations to subscript besides that it has to have storageKeyPath that accepts a key path.

1 Like