Cannot name a 'oneof' field 'option' if an optional field exists
Closed this issue · 1 comments
alexesom commented
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:
- 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;
}
}
- Compile
.proto
file - Observe the resulting error in
object PaymentMethod
within theparseFrom
function: "object Option in object PaymentMethod does not take parameters."
thesamet commented
Thanks for reporting and providing the steps to reproduce. Fixed!