As I understand, having out here basically makes an instance of MessageField returned by this method read-only (by removing parts of its API that accept it as an input). If so, as far as I can see, having out in such returned MessageField values in this API and similar ones degrades its applicability since such fields cannot be modified without unchecked typecasting.
So, preliminarily, I would consider having such out clauses near MessageFieldValue of MessageFields which are returned from our runtime codegen API to be worth removing. This is a fine topic though, so I believe we'd need to weigh and discuss this, and possibly see if this doesn't cause further issues, before accepting this as a final change.
Here's an example of such a method in
MessageOneof
: https://github.com/SpineEventEngine/Chords/blob/3169ad3d96fc59ed4eaf41d973356d02d731254c/codegen/runtime/src/main/kotlin/io/spine/chords/runtime/MessageOneof.kt#L57As I understand, having
out
here basically makes an instance ofMessageField
returned by this method read-only (by removing parts of its API that accept it as an input). If so, as far as I can see, havingout
in such returnedMessageField
values in this API and similar ones degrades its applicability since such fields cannot be modified without unchecked typecasting.For this particular one I've stumbled onto a case where I needed to perform an unchecked cast like this to bring it back to a "writable" form: see here: https://github.com/SpineEventEngine/Chords/blob/f4c572a04298c839230449d61cea893e5c2fa0ed/proto/src/main/kotlin/io/spine/chords/proto/form/MessageForm.kt#L1289
So, preliminarily, I would consider having such
out
clauses nearMessageFieldValue
ofMessageField
s which are returned from our runtime codegen API to be worth removing. This is a fine topic though, so I believe we'd need to weigh and discuss this, and possibly see if this doesn't cause further issues, before accepting this as a final change.