From 8dec8bf3aa567d9be26113dcea7515137072cc44 Mon Sep 17 00:00:00 2001 From: kenji yoshida <6b656e6a69@gmail.com> Date: Sun, 26 Feb 2023 06:01:41 +0900 Subject: [PATCH] add `asRecognized` method in GeneratedEnum (#1489) --- build.sbt | 1 + .../src/main/scala/scalapb/compiler/ProtobufGenerator.scala | 1 + docs/src/main/scala/generated/scalapb/docs/person/Person.scala | 1 + docs/src/main/scala/generated/scalapb/perf/protos/Color.scala | 1 + .../protobuf/compiler/plugin/CodeGeneratorResponse.scala | 1 + .../com/google/protobuf/descriptor/FieldDescriptorProto.scala | 2 ++ .../com/google/protobuf/descriptor/FieldOptions.scala | 2 ++ .../js-native/com/google/protobuf/descriptor/FileOptions.scala | 1 + .../com/google/protobuf/descriptor/MethodOptions.scala | 1 + .../main/js-native/com/google/protobuf/struct/NullValue.scala | 1 + .../src/main/js-native/com/google/protobuf/type/Field.scala | 2 ++ .../src/main/js-native/com/google/protobuf/type/Syntax.scala | 1 + .../src/main/scala/scalapb/GeneratedMessageCompanion.scala | 3 +++ scalapb-runtime/src/main/scala/scalapb/options/MatchType.scala | 1 + .../src/main/scala/scalapb/options/ScalaPbOptions.scala | 2 ++ .../protobuf/compiler/plugin/CodeGeneratorResponse.scala | 1 + .../com/google/protobuf/descriptor/FieldDescriptorProto.scala | 2 ++ .../scalajvm/com/google/protobuf/descriptor/FieldOptions.scala | 2 ++ .../scalajvm/com/google/protobuf/descriptor/FileOptions.scala | 1 + .../com/google/protobuf/descriptor/MethodOptions.scala | 1 + .../main/scalajvm/com/google/protobuf/struct/NullValue.scala | 1 + .../src/main/scalajvm/com/google/protobuf/type/Field.scala | 2 ++ .../src/main/scalajvm/com/google/protobuf/type/Syntax.scala | 1 + 23 files changed, 32 insertions(+) diff --git a/build.sbt b/build.sbt index 36ee88677..c5ee499c5 100644 --- a/build.sbt +++ b/build.sbt @@ -64,6 +64,7 @@ lazy val runtime = (projectMatrix in file("scalapb-runtime")) else Nil), mimaPreviousArtifacts := Set("com.thesamet.scalapb" %% "scalapb-runtime" % MimaPreviousVersion), mimaBinaryIssueFilters ++= Seq( + ProblemFilters.exclude[ReversedMissingMethodProblem]("scalapb.GeneratedEnum.asRecognized"), ProblemFilters.exclude[InheritedNewAbstractMethodProblem]("*Extension*"), ProblemFilters.exclude[Problem]("scalapb.options.*"), ProblemFilters.exclude[FinalMethodProblem]("*.parseFrom") diff --git a/compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala b/compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala index 1862450f9..fde1ec725 100644 --- a/compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala +++ b/compiler-plugin/src/main/scala/scalapb/compiler/ProtobufGenerator.scala @@ -36,6 +36,7 @@ class ProtobufGenerator( ) .indent .add(s"type EnumType = $name") + .add(s"type RecognizedType = ${e.recognizedEnum.fullName}") .print(e.getValues.asScala) { case (p, v) => p.add(s"def ${v.isName}: _root_.scala.Boolean = false") } diff --git a/docs/src/main/scala/generated/scalapb/docs/person/Person.scala b/docs/src/main/scala/generated/scalapb/docs/person/Person.scala index 517c1a6d6..cd61f24a9 100644 --- a/docs/src/main/scala/generated/scalapb/docs/person/Person.scala +++ b/docs/src/main/scala/generated/scalapb/docs/person/Person.scala @@ -164,6 +164,7 @@ object Person extends scalapb.GeneratedMessageCompanion[scalapb.docs.person.Pers ) sealed abstract class AddressType(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = AddressType + type RecognizedType = scalapb.docs.person.Person.AddressType.Recognized def isHome: _root_.scala.Boolean = false def isWork: _root_.scala.Boolean = false def companion: _root_.scalapb.GeneratedEnumCompanion[AddressType] = scalapb.docs.person.Person.AddressType diff --git a/docs/src/main/scala/generated/scalapb/perf/protos/Color.scala b/docs/src/main/scala/generated/scalapb/perf/protos/Color.scala index f358b8a93..bd77b5523 100644 --- a/docs/src/main/scala/generated/scalapb/perf/protos/Color.scala +++ b/docs/src/main/scala/generated/scalapb/perf/protos/Color.scala @@ -7,6 +7,7 @@ package scalapb.perf.protos sealed abstract class Color(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Color + type RecognizedType = scalapb.perf.protos.Color.Recognized def isUnknown: _root_.scala.Boolean = false def isRed: _root_.scala.Boolean = false def isGreen: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/js-native/com/google/protobuf/compiler/plugin/CodeGeneratorResponse.scala b/scalapb-runtime/src/main/js-native/com/google/protobuf/compiler/plugin/CodeGeneratorResponse.scala index 4fbb74b8a..b208b7934 100644 --- a/scalapb-runtime/src/main/js-native/com/google/protobuf/compiler/plugin/CodeGeneratorResponse.scala +++ b/scalapb-runtime/src/main/js-native/com/google/protobuf/compiler/plugin/CodeGeneratorResponse.scala @@ -169,6 +169,7 @@ object CodeGeneratorResponse extends scalapb.GeneratedMessageCompanion[com.googl */ sealed abstract class Feature(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Feature + type RecognizedType = com.google.protobuf.compiler.plugin.CodeGeneratorResponse.Feature.Recognized def isFeatureNone: _root_.scala.Boolean = false def isFeatureProto3Optional: _root_.scala.Boolean = false def companion: _root_.scalapb.GeneratedEnumCompanion[Feature] = com.google.protobuf.compiler.plugin.CodeGeneratorResponse.Feature diff --git a/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FieldDescriptorProto.scala b/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FieldDescriptorProto.scala index 74035b5db..a95aad9aa 100644 --- a/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FieldDescriptorProto.scala +++ b/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FieldDescriptorProto.scala @@ -364,6 +364,7 @@ object FieldDescriptorProto extends scalapb.GeneratedMessageCompanion[com.google ) sealed abstract class Type(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Type + type RecognizedType = com.google.protobuf.descriptor.FieldDescriptorProto.Type.Recognized def isTypeDouble: _root_.scala.Boolean = false def isTypeFloat: _root_.scala.Boolean = false def isTypeInt64: _root_.scala.Boolean = false @@ -567,6 +568,7 @@ object FieldDescriptorProto extends scalapb.GeneratedMessageCompanion[com.google } sealed abstract class Label(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Label + type RecognizedType = com.google.protobuf.descriptor.FieldDescriptorProto.Label.Recognized def isLabelOptional: _root_.scala.Boolean = false def isLabelRequired: _root_.scala.Boolean = false def isLabelRepeated: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FieldOptions.scala b/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FieldOptions.scala index a4bda96b2..6387cc433 100644 --- a/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FieldOptions.scala +++ b/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FieldOptions.scala @@ -296,6 +296,7 @@ object FieldOptions extends scalapb.GeneratedMessageCompanion[com.google.protobu ) sealed abstract class CType(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = CType + type RecognizedType = com.google.protobuf.descriptor.FieldOptions.CType.Recognized def isString: _root_.scala.Boolean = false def isCord: _root_.scala.Boolean = false def isStringPiece: _root_.scala.Boolean = false @@ -344,6 +345,7 @@ object FieldOptions extends scalapb.GeneratedMessageCompanion[com.google.protobu } sealed abstract class JSType(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = JSType + type RecognizedType = com.google.protobuf.descriptor.FieldOptions.JSType.Recognized def isJsNormal: _root_.scala.Boolean = false def isJsString: _root_.scala.Boolean = false def isJsNumber: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FileOptions.scala b/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FileOptions.scala index 0bf3322bd..37488f8eb 100644 --- a/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FileOptions.scala +++ b/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/FileOptions.scala @@ -596,6 +596,7 @@ object FileOptions extends scalapb.GeneratedMessageCompanion[com.google.protobuf */ sealed abstract class OptimizeMode(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = OptimizeMode + type RecognizedType = com.google.protobuf.descriptor.FileOptions.OptimizeMode.Recognized def isSpeed: _root_.scala.Boolean = false def isCodeSize: _root_.scala.Boolean = false def isLiteRuntime: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/MethodOptions.scala b/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/MethodOptions.scala index c91c1cc73..9aca0e035 100644 --- a/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/MethodOptions.scala +++ b/scalapb-runtime/src/main/js-native/com/google/protobuf/descriptor/MethodOptions.scala @@ -165,6 +165,7 @@ object MethodOptions extends scalapb.GeneratedMessageCompanion[com.google.protob */ sealed abstract class IdempotencyLevel(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = IdempotencyLevel + type RecognizedType = com.google.protobuf.descriptor.MethodOptions.IdempotencyLevel.Recognized def isIdempotencyUnknown: _root_.scala.Boolean = false def isNoSideEffects: _root_.scala.Boolean = false def isIdempotent: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/js-native/com/google/protobuf/struct/NullValue.scala b/scalapb-runtime/src/main/js-native/com/google/protobuf/struct/NullValue.scala index c3c0641e8..fc3e06827 100644 --- a/scalapb-runtime/src/main/js-native/com/google/protobuf/struct/NullValue.scala +++ b/scalapb-runtime/src/main/js-native/com/google/protobuf/struct/NullValue.scala @@ -12,6 +12,7 @@ package com.google.protobuf.struct */ sealed abstract class NullValue(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = NullValue + type RecognizedType = com.google.protobuf.struct.NullValue.Recognized def isNullValue: _root_.scala.Boolean = false def companion: _root_.scalapb.GeneratedEnumCompanion[NullValue] = com.google.protobuf.struct.NullValue final def asRecognized: _root_.scala.Option[com.google.protobuf.struct.NullValue.Recognized] = if (isUnrecognized) _root_.scala.None else _root_.scala.Some(this.asInstanceOf[com.google.protobuf.struct.NullValue.Recognized]) diff --git a/scalapb-runtime/src/main/js-native/com/google/protobuf/type/Field.scala b/scalapb-runtime/src/main/js-native/com/google/protobuf/type/Field.scala index 96ee3d31b..84f78d176 100644 --- a/scalapb-runtime/src/main/js-native/com/google/protobuf/type/Field.scala +++ b/scalapb-runtime/src/main/js-native/com/google/protobuf/type/Field.scala @@ -375,6 +375,7 @@ object Field extends scalapb.GeneratedMessageCompanion[com.google.protobuf.`type */ sealed abstract class Kind(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Kind + type RecognizedType = com.google.protobuf.`type`.Field.Kind.Recognized def isTypeUnknown: _root_.scala.Boolean = false def isTypeDouble: _root_.scala.Boolean = false def isTypeFloat: _root_.scala.Boolean = false @@ -605,6 +606,7 @@ object Field extends scalapb.GeneratedMessageCompanion[com.google.protobuf.`type */ sealed abstract class Cardinality(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Cardinality + type RecognizedType = com.google.protobuf.`type`.Field.Cardinality.Recognized def isCardinalityUnknown: _root_.scala.Boolean = false def isCardinalityOptional: _root_.scala.Boolean = false def isCardinalityRequired: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/js-native/com/google/protobuf/type/Syntax.scala b/scalapb-runtime/src/main/js-native/com/google/protobuf/type/Syntax.scala index b884739a3..2897d882f 100644 --- a/scalapb-runtime/src/main/js-native/com/google/protobuf/type/Syntax.scala +++ b/scalapb-runtime/src/main/js-native/com/google/protobuf/type/Syntax.scala @@ -9,6 +9,7 @@ package com.google.protobuf.`type` */ sealed abstract class Syntax(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Syntax + type RecognizedType = com.google.protobuf.`type`.Syntax.Recognized def isSyntaxProto2: _root_.scala.Boolean = false def isSyntaxProto3: _root_.scala.Boolean = false def companion: _root_.scalapb.GeneratedEnumCompanion[Syntax] = com.google.protobuf.`type`.Syntax diff --git a/scalapb-runtime/src/main/scala/scalapb/GeneratedMessageCompanion.scala b/scalapb-runtime/src/main/scala/scalapb/GeneratedMessageCompanion.scala index 032a0db0d..f2710737c 100644 --- a/scalapb-runtime/src/main/scala/scalapb/GeneratedMessageCompanion.scala +++ b/scalapb-runtime/src/main/scala/scalapb/GeneratedMessageCompanion.scala @@ -12,6 +12,7 @@ import scala.annotation.nowarn trait GeneratedEnum extends Any with Product with Serializable { type EnumType <: GeneratedEnum + type RecognizedType <: EnumType def value: Int @@ -30,6 +31,8 @@ trait GeneratedEnum extends Any with Product with Serializable { def scalaValueDescriptor: _root_.scalapb.descriptors.EnumValueDescriptor = companion.scalaDescriptor.values(index) + + def asRecognized: Option[RecognizedType] } trait UnrecognizedEnum extends GeneratedEnum { diff --git a/scalapb-runtime/src/main/scala/scalapb/options/MatchType.scala b/scalapb-runtime/src/main/scala/scalapb/options/MatchType.scala index 29863aeac..4c91c5034 100644 --- a/scalapb-runtime/src/main/scala/scalapb/options/MatchType.scala +++ b/scalapb-runtime/src/main/scala/scalapb/options/MatchType.scala @@ -7,6 +7,7 @@ package scalapb.options sealed abstract class MatchType(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = MatchType + type RecognizedType = scalapb.options.MatchType.Recognized def isContains: _root_.scala.Boolean = false def isExact: _root_.scala.Boolean = false def isPresence: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/scala/scalapb/options/ScalaPbOptions.scala b/scalapb-runtime/src/main/scala/scalapb/options/ScalaPbOptions.scala index 8e9563479..0613bc248 100644 --- a/scalapb-runtime/src/main/scala/scalapb/options/ScalaPbOptions.scala +++ b/scalapb-runtime/src/main/scala/scalapb/options/ScalaPbOptions.scala @@ -759,6 +759,7 @@ object ScalaPbOptions extends scalapb.GeneratedMessageCompanion[scalapb.options. */ sealed abstract class OptionsScope(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = OptionsScope + type RecognizedType = scalapb.options.ScalaPbOptions.OptionsScope.Recognized def isFile: _root_.scala.Boolean = false def isPackage: _root_.scala.Boolean = false def companion: _root_.scalapb.GeneratedEnumCompanion[OptionsScope] = scalapb.options.ScalaPbOptions.OptionsScope @@ -802,6 +803,7 @@ object ScalaPbOptions extends scalapb.GeneratedMessageCompanion[scalapb.options. */ sealed abstract class EnumValueNaming(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = EnumValueNaming + type RecognizedType = scalapb.options.ScalaPbOptions.EnumValueNaming.Recognized def isAsInProto: _root_.scala.Boolean = false def isCamelCase: _root_.scala.Boolean = false def companion: _root_.scalapb.GeneratedEnumCompanion[EnumValueNaming] = scalapb.options.ScalaPbOptions.EnumValueNaming diff --git a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/compiler/plugin/CodeGeneratorResponse.scala b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/compiler/plugin/CodeGeneratorResponse.scala index a631f1541..9ff32e58b 100644 --- a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/compiler/plugin/CodeGeneratorResponse.scala +++ b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/compiler/plugin/CodeGeneratorResponse.scala @@ -182,6 +182,7 @@ object CodeGeneratorResponse extends scalapb.GeneratedMessageCompanion[com.googl */ sealed abstract class Feature(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Feature + type RecognizedType = com.google.protobuf.compiler.plugin.CodeGeneratorResponse.Feature.Recognized def isFeatureNone: _root_.scala.Boolean = false def isFeatureProto3Optional: _root_.scala.Boolean = false def companion: _root_.scalapb.GeneratedEnumCompanion[Feature] = com.google.protobuf.compiler.plugin.CodeGeneratorResponse.Feature diff --git a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/FieldDescriptorProto.scala b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/FieldDescriptorProto.scala index 817b536c5..84f89e450 100644 --- a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/FieldDescriptorProto.scala +++ b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/FieldDescriptorProto.scala @@ -392,6 +392,7 @@ object FieldDescriptorProto extends scalapb.GeneratedMessageCompanion[com.google ) sealed abstract class Type(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Type + type RecognizedType = com.google.protobuf.descriptor.FieldDescriptorProto.Type.Recognized def isTypeDouble: _root_.scala.Boolean = false def isTypeFloat: _root_.scala.Boolean = false def isTypeInt64: _root_.scala.Boolean = false @@ -600,6 +601,7 @@ object FieldDescriptorProto extends scalapb.GeneratedMessageCompanion[com.google } sealed abstract class Label(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Label + type RecognizedType = com.google.protobuf.descriptor.FieldDescriptorProto.Label.Recognized def isLabelOptional: _root_.scala.Boolean = false def isLabelRequired: _root_.scala.Boolean = false def isLabelRepeated: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/FieldOptions.scala b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/FieldOptions.scala index 71271d27f..6633ff6a9 100644 --- a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/FieldOptions.scala +++ b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/FieldOptions.scala @@ -317,6 +317,7 @@ object FieldOptions extends scalapb.GeneratedMessageCompanion[com.google.protobu ) sealed abstract class CType(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = CType + type RecognizedType = com.google.protobuf.descriptor.FieldOptions.CType.Recognized def isString: _root_.scala.Boolean = false def isCord: _root_.scala.Boolean = false def isStringPiece: _root_.scala.Boolean = false @@ -370,6 +371,7 @@ object FieldOptions extends scalapb.GeneratedMessageCompanion[com.google.protobu } sealed abstract class JSType(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = JSType + type RecognizedType = com.google.protobuf.descriptor.FieldOptions.JSType.Recognized def isJsNormal: _root_.scala.Boolean = false def isJsString: _root_.scala.Boolean = false def isJsNumber: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/FileOptions.scala b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/FileOptions.scala index 6d285989a..b6c1c79d3 100644 --- a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/FileOptions.scala +++ b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/FileOptions.scala @@ -645,6 +645,7 @@ object FileOptions extends scalapb.GeneratedMessageCompanion[com.google.protobuf */ sealed abstract class OptimizeMode(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = OptimizeMode + type RecognizedType = com.google.protobuf.descriptor.FileOptions.OptimizeMode.Recognized def isSpeed: _root_.scala.Boolean = false def isCodeSize: _root_.scala.Boolean = false def isLiteRuntime: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/MethodOptions.scala b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/MethodOptions.scala index 5aea55f1f..5c033304c 100644 --- a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/MethodOptions.scala +++ b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/descriptor/MethodOptions.scala @@ -178,6 +178,7 @@ object MethodOptions extends scalapb.GeneratedMessageCompanion[com.google.protob */ sealed abstract class IdempotencyLevel(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = IdempotencyLevel + type RecognizedType = com.google.protobuf.descriptor.MethodOptions.IdempotencyLevel.Recognized def isIdempotencyUnknown: _root_.scala.Boolean = false def isNoSideEffects: _root_.scala.Boolean = false def isIdempotent: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/struct/NullValue.scala b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/struct/NullValue.scala index 500366af6..e49fbeec9 100644 --- a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/struct/NullValue.scala +++ b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/struct/NullValue.scala @@ -12,6 +12,7 @@ package com.google.protobuf.struct */ sealed abstract class NullValue(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = NullValue + type RecognizedType = com.google.protobuf.struct.NullValue.Recognized def isNullValue: _root_.scala.Boolean = false def companion: _root_.scalapb.GeneratedEnumCompanion[NullValue] = com.google.protobuf.struct.NullValue final def asRecognized: _root_.scala.Option[com.google.protobuf.struct.NullValue.Recognized] = if (isUnrecognized) _root_.scala.None else _root_.scala.Some(this.asInstanceOf[com.google.protobuf.struct.NullValue.Recognized]) diff --git a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/type/Field.scala b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/type/Field.scala index 76aa21f64..aa1ba9d52 100644 --- a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/type/Field.scala +++ b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/type/Field.scala @@ -402,6 +402,7 @@ object Field extends scalapb.GeneratedMessageCompanion[com.google.protobuf.`type */ sealed abstract class Kind(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Kind + type RecognizedType = com.google.protobuf.`type`.Field.Kind.Recognized def isTypeUnknown: _root_.scala.Boolean = false def isTypeDouble: _root_.scala.Boolean = false def isTypeFloat: _root_.scala.Boolean = false @@ -637,6 +638,7 @@ object Field extends scalapb.GeneratedMessageCompanion[com.google.protobuf.`type */ sealed abstract class Cardinality(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Cardinality + type RecognizedType = com.google.protobuf.`type`.Field.Cardinality.Recognized def isCardinalityUnknown: _root_.scala.Boolean = false def isCardinalityOptional: _root_.scala.Boolean = false def isCardinalityRequired: _root_.scala.Boolean = false diff --git a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/type/Syntax.scala b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/type/Syntax.scala index 33add2b24..176c025b2 100644 --- a/scalapb-runtime/src/main/scalajvm/com/google/protobuf/type/Syntax.scala +++ b/scalapb-runtime/src/main/scalajvm/com/google/protobuf/type/Syntax.scala @@ -9,6 +9,7 @@ package com.google.protobuf.`type` */ sealed abstract class Syntax(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum { type EnumType = Syntax + type RecognizedType = com.google.protobuf.`type`.Syntax.Recognized def isSyntaxProto2: _root_.scala.Boolean = false def isSyntaxProto3: _root_.scala.Boolean = false def companion: _root_.scalapb.GeneratedEnumCompanion[Syntax] = com.google.protobuf.`type`.Syntax