ScalaPB icon indicating copy to clipboard operation
ScalaPB copied to clipboard

Add an option to generate oneof fields as a sealed abstract class

Open joroKr21 opened this issue 1 year ago • 0 comments

Currently oneof fields are generated as sealed traits with every variant resulting in two methods to the trait:

  • isFoo: Boolean
  • foo: 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.

joroKr21 avatar May 19 '24 05:05 joroKr21