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

Cannot name a 'oneof' field 'option' if an optional field exists #1623

Closed
alexesom opened this issue Dec 29, 2023 · 1 comment
Closed

Cannot name a 'oneof' field 'option' if an optional field exists #1623

alexesom opened this issue Dec 29, 2023 · 1 comment

Comments

@alexesom
Copy link

alexesom commented Dec 29, 2023

This issue is also potentially connected with #1462.

Problem description:
When a .proto file contains a message with both a nested message field and a oneof field named option, the scalapb compiler generates an object Option and in the parseFrom method's pattern matching, it uses Option without specifying the Scala package (_root_.scala.Option). This causes the Scala compiler to produce an error, as it interprets Option as the generated object Option rather than the standard Scala Option, which does not take parameters.

Steps to reproduce:

  1. Create PaymentMethod.proto file with contents:
message PaymentMethod {
  string id = 1;
  Money amount = 2;
  oneof option {
    CreditCard credit_card = 3;
    DebitCard debit_card = 4;
    PayPal pay_pal = 5;
  }
}
  1. Compile .proto file
  2. Observe the resulting error in object PaymentMethod within the parseFrom function: "object Option in object PaymentMethod does not take parameters."
@thesamet
Copy link
Contributor

Thanks for reporting and providing the steps to reproduce. Fixed!

thesamet added a commit that referenced this issue Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants