Mixins need to enforce read-only behavior for default instance
Open
- Dominant language
- Dart
- Stars
- 572
- Forks
- 196
- Avg merge
- 1h 59m
- Merged PRs (30d)
- 2
Description
For each protobuf class there is a default instance, which should be read-only. Mixins may add extra fields and a way to set them. Any mixin with a setter should throw an exception if the instance is read-only.
Currently the _isReadOnly getter is private. We should make it public. In the meantime, a mixin can implement the check like this:
```
if (this is ReadonlyMessageMixin) {
throw new UnsupportedError(
"attempted to set on a read-only message (${info_.messageName})");
}
```
Contributor guide
Assessment
This issue has not been assessed yet.