Using RawRepresentable String and Int keys for Codable Dictionaries

Hi all,
I’m bumping this topic on request from @Tony_Parker on the discussion on the PR mentioned earlier: [WIP] Using RawRepresentable String keys for Dictionaries with JSONEncoder and JSONDecoder by mortenbekditlevsen · Pull Request #26257 · apple/swift · GitHub

To summarize the discussion so far:
Currently Dictionaries that are not either String or Int keyed will encode and decode as key-value pairs rather than as dictionaries.
This happens even though the keys may be RawRepresentable as Strings or Ints.

It could be desirable to have those RawRepresentable keys make Dictionaries encode and decode as dictionaries - and it could even be desirable to get this functionality if the keys could just be encoded/decided to/from single value containers containing a String or an Int.

The options as I remember them are:

  1. Do nothing
  2. Consider current behavior to be a bug and change the behavior. This is problems since the behavior is tied to the platform (iOS 13 gets current behavior while a future iOS release could get the new). I don’t think that this option is realistic even though I would personally like to consider the current behavior to be a bug.
  3. Create a shared ‘marker’ protocol for opting in to this behavior for each key type, but for all encoders and decoders.
  4. Fix this with new encoding/decoding options per encoder - as the mentioned PR does for JSONEncoder by adding a new ‘dictionary encoding strategy’.
  5. Perhaps this could be fixed using ‘new type’ if that will become part of the language. This would not fix the general issue, but at least it could perhaps be made to work for types that are ‘new types’ of String and Int. Just speculating here, since I am not very familiar with how newtype might actually work.

For me the most elegant option would be number 2, but as mentioned I am guessing that this can’t be chosen.

Can anyone help with suggestions for this issue?