diff --git a/CHANGELOG.md b/CHANGELOG.md index be2b7ef5d..ccc3e2dfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Bump protobuf and protoc to 4.26.0. Currently files must specify proto2 and proto3 syntax. Editions are not supported yet. - References to descriptors are fully qualified (#1724) +- Oneofs are now generated as sealed abstract class instead of sealed traits (#1694) ## [0.11.18] (Unreleased) - References to descriptors are fully qualified (#1724) diff --git a/compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala b/compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala index edfa7f28a..b366312e8 100644 --- a/compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala +++ b/compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala @@ -115,7 +115,9 @@ class ProtobufGenerator( def printOneof(printer: FunctionalPrinter, e: OneofDescriptor): FunctionalPrinter = { printer - .add(s"sealed trait ${e.scalaType.nameSymbol} extends ${e.baseClasses.mkString(" with ")} {") + .add( + s"sealed abstract class ${e.scalaType.nameSymbol} extends ${e.baseClasses.mkString(" with ")} {" + ) .indent .add(s"def isEmpty: _root_.scala.Boolean = false") .add(s"def isDefined: _root_.scala.Boolean = true") diff --git a/scalapb-runtime/src/main/js-native/com/google/protobuf/struct/Value.scala b/scalapb-runtime/src/main/js-native/com/google/protobuf/struct/Value.scala index 209be8958..02d86912d 100644 --- a/scalapb-runtime/src/main/js-native/com/google/protobuf/struct/Value.scala +++ b/scalapb-runtime/src/main/js-native/com/google/protobuf/struct/Value.scala @@ -195,7 +195,7 @@ object Value extends scalapb.GeneratedMessageCompanion[com.google.protobuf.struc lazy val defaultInstance = com.google.protobuf.struct.Value( kind = com.google.protobuf.struct.Value.Kind.Empty ) - sealed trait Kind extends _root_.scalapb.GeneratedOneof { + sealed abstract class Kind extends _root_.scalapb.GeneratedOneof { def isEmpty: _root_.scala.Boolean = false def isDefined: _root_.scala.Boolean = true def isNullValue: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/struct/Value.scala b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/struct/Value.scala index def63f88d..597554f2c 100644 --- a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/struct/Value.scala +++ b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/struct/Value.scala @@ -216,7 +216,7 @@ object Value extends scalapb.GeneratedMessageCompanion[com.google.protobuf.struc lazy val defaultInstance = com.google.protobuf.struct.Value( kind = com.google.protobuf.struct.Value.Kind.Empty ) - sealed trait Kind extends _root_.scalapb.GeneratedOneof { + sealed abstract class Kind extends _root_.scalapb.GeneratedOneof { def isEmpty: _root_.scala.Boolean = false def isDefined: _root_.scala.Boolean = true def isNullValue: _root_.scala.Boolean = false