scalapb/ScalaPB

Sealed oneof "extend" for Empty case

nodefactory-bk opened this issue · 1 comments

Hi!

It would be very useful to be able to extend the Empty case of a sealed oneof just as we can extend the other cases.

For example these code snippets:

trait Base {
  def foo(): Unit
}

trait BaseA extends Base {
  override def foo() = println("bar")
}
message Seal {
    option (scalapb.message).sealed_oneof_extends = "Base";

    oneof sealed_value {
        CaseA a = 1;
    }
}

message CaseA {
    option (scalapb.message).extends = "BaseA";
}

will result in the error:

[error] Missing implementation for member of trait Base:
[error]   def foo(): Unit = ???
[error]   case object Empty extends Seal

which is reasonable because it indeed doesn't have its foo. =)

An option like option (scalapb.message).sealed_oneof_empty_extends = "BaseEmpty"; would be very useful for these cases.
(or any other way to get Empty to extend something).

Ps. Slightly unrelated but is there a way to post-process the generated code? Can't remember seeing anything about ut in the docs.

/B

Awesome! Thanks!