ScalaPB
ScalaPB copied to clipboard
Add an option to generate oneof fields as a sealed abstract class
Currently oneof fields are generated as sealed traits with every variant resulting in two methods to the trait:
isFoo: Booleanfoo: Option[Foo]
Because it's a trait, the methods are mixed in to the $n$ subclasses (variants). So in total, there are $2n^2$ methods generated.
In contrast, Abstract class methods are not mixed in. So for oneof fields with many variants, it would be beneficial to generate an abstract class.