-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UseResult
annotation to rebuild
#631
Conversation
This catches issues like google#630 where we forgot to use return value of `rebuild`. Since `rebuild` does not update in-place, not using the return value is often a bug. This adds `meta` as a dependency but it should not affect generated code. We may also want to use `meta` in the future for things like: - Annotating `GeneratedMessage` methods that are supposed to be used by the generated code with `@protected`. - Annotating generated message classes with `@sealed`. This help with maintaining backwards compatibility when adding new members to generated messages or to `GeneratedMessage`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Seems there is a test that needs to be fixed.
Maybe @rakudrama has something to say about adding the dependency.
I think package:meta is so ubiquitous that package:protobuf can afford to depend on it.
Hm.. I'm a bit surprised that this line generates a
The result is clearly used. It's casted to So this generates a warning: var copy1 = foo.deepCopy().freeze().rebuild((_) {}) as Foo;
expectOneofNotSet(copy1); But this does not: var copy1 = foo.deepCopy().freeze().rebuild((_) {});
expectOneofNotSet(copy1 as Foo); |
Reported this as dart-lang/sdk#48879. |
The issue with the warning described above is fixed in Dart |
I think it is ok to add a |
@rakudrama any thoughts on adding |
I don't foresee any problems. |
Side comment - |
This is because protobuf.dart/protobuf/lib/src/protobuf/generated_message.dart Lines 54 to 57 in 9c73821
freeze .
It would be great if we could use a type like |
This revealed another SDK bug when updating a protobuf user to the current master branch: dart-lang/sdk#49023 |
This catches issues like #630 where we forgot to use return value of
rebuild
. Sincerebuild
does not update in-place, not using thereturn value is often a bug.
This adds
meta
as a dependency but it should not affect generatedcode. We may also want to use
meta
in the future for things like:Annotating
GeneratedMessage
methods that are supposed to be used bythe generated code with
@protected
.Annotating generated message classes with
@sealed
. This help withmaintaining backwards compatibility when adding new members to
generated messages or to
GeneratedMessage
.