scalapb/ScalaPB

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

joroKr21 opened this issue · 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.