-
-
Notifications
You must be signed in to change notification settings - Fork 292
Open
Description
When using oneof in ScalaPB with the sealed_value_optional
and using it as single message it get's wrapped into an Option
, but repeated fields get wrapped as Seq[Option[T]]
instead of the expected Seq[T]
.
This inconsistency differs from how ScalaPB handles other repeated fields/messages (without oneof), which are typically wrapped directly in Seq[T]. Here’s a breakdown of the problem and generated code behavior:
message TestMessage {
oneof sealed_value {
StringWrapper1 bla = 1;
StringWrapper2 xa = 2;
}
}
message TestMessage2 {
oneof sealed_value_optional {
StringWrapper3 blzza = 1;
StringWrapper4 xazz = 2;
}
}
message ProperMessage {
google.protobuf.StringValue test = 1;
google.protobuf.Timestamp test2 = 2;
google.protobuf.BoolValue test3 = 3;
}
message BiggerMessage {
TestMessage message = 1; // -> TestMessage = TestMessageMessage.SealedValue.Empty
repeated TestMessage messages = 2; // -> Seq[TestMessage] = Seq.empty
TestMessage2 message2 = 3; // -> Option[TestMessage2] = None
repeated TestMessage2 messages2 = 4; // -> Seq[Option[TestMessage2]] = Seq.empty
repeated TestMessage2 messages3 = 5; // [(scalapb.field).type = "scala.collection.immutable.Seq[...TestMessage2]"]
// ^^ does not work because sealed oneofs can't be type mapped
repeated ProperMessage test3 = 6; // -> generated -> Seq[ProperMessage] = Seq.empty
}
Metadata
Metadata
Assignees
Labels
No labels