Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add map test cases to no_field_presence_test.
Maps behave in a very interesting way if they are set to be implicit-presence fields. They present the possibility that the key or value (or both) can be the default zero value. When that happens, access to the key or the value is unaffected. In this case, presence is a bit of a meaningless concept. Zero keys are valid as map indices, and if a map entry is set to zero, it just always exists. Reflection is a little weird too. - If you do reflection on a normal integer field and ask if a zero-valued field exists, it will tell you that it doesn't exist. This is consistent with what "implicit presence" means. - If you do reflection on a zero integer field that happens to be a map key, it will tell you that it exists. Fetching the value of map[0] is equally valid. (Note that this is not exactly *intended*, but it's just hard to change... and this implementation results in simpler gencode.) I'm adding unit tests in no_field_presence_test to cover this quirk. PiperOrigin-RevId: 676268392
- Loading branch information