Skip to content
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

proto3 hazzers always generated #767

Open
kutoman opened this issue Oct 30, 2022 · 2 comments
Open

proto3 hazzers always generated #767

kutoman opened this issue Oct 30, 2022 · 2 comments
Labels

Comments

@kutoman
Copy link

kutoman commented Oct 30, 2022

I'm not sure whether this is an issue or intended. In the generated dart code the has.. method is always generated for a corresponding message field regardless of being labeled as optional or not. Does it make sense to generate those methods for none-optional fields?

@osa1
Copy link
Member

osa1 commented Nov 1, 2022

Yes. We have a TODO about this in the code:

// TODO(sigurdm): to provide the correct semantics for non-optional proto3
// fields would need something like the following:
// return baseType.isMessage ||
// descriptor.proto3Optional ||
// parent.fileGen.descriptor.syntax == "proto2";
//
// This change would break any accidental uses of the proto3 hazzers, and
// would require some clean-up.
//
// We could consider keeping hazzers for proto3-oneof fields. There they
// seem useful and not breaking proto3 semantics, and dart protobuf uses it
// for example in package:protobuf/src/protobuf/mixins/well_known.dart.
this was added in 1319847 which implemented proto3 optional syntax.

@osa1 osa1 added the bug label Nov 1, 2022
@osa1 osa1 changed the title proto3 hasMETHOD always generated proto3 hazzers always generated Nov 2, 2022
@kutoman
Copy link
Author

kutoman commented Nov 4, 2022

oh I see. I didn't check the generator's code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants