Enum Case KeyPaths

The language workgroup discussed this proposal during our most recent meeting, and we'd like to see a few things planned out before proceeding with bringing this proposal to review:

  • We would like to have a clear idea of how projection syntax should look to access the payload of an enum case from an enum value. We don't need this feature to be implemented and accepted as a prerequisite to reviewing enum key paths, but we want to make sure that convergent evolution is possible here between enumValue.<enum case reference> and \EnumType.<enum case reference>, however that looks.
  • Although this proposal does not provide an ability to write through enum key paths, or to inject a payload into the enum case to produce a value of the enum, we want to be sure that we can add that functionality in the future. We should have reasonable confidence that the design and implementation allows for key paths involving enum cases to gain those capabilities in the future.
  • Relatedly, it would also be good to have an idea of how in-place mutation of conditionally-available storage should work in the language, such as getting an inout handle to an enum case payload, since this should relate to how conditionally-writable key paths involving enum cases are written through.

Again, we don't need full proposals or implementations for these related features; we only want to make sure we're incrementally evolving the language in a direction that aligns with future directions.