Skip to content

Commit

Permalink
fix issue where generated code does not allows fully reference _root_…
Browse files Browse the repository at this point in the history
….scala.Option (#1747)
  • Loading branch information
pjfanning authored Oct 2, 2024
1 parent c4a3b85 commit f422f2e
Show file tree
Hide file tree
Showing 72 changed files with 351 additions and 351 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ class ProtobufGenerator(
.when(field.supportsPresence) { p =>
p.add(
s"""def $clearMethod: ${message.scalaType.nameSymbol} = copy(${field.scalaName.asSymbol} = ${C.None})
|def $withMethod(__v: ${singleType}): ${message.scalaType.nameSymbol} = copy(${field.scalaName.asSymbol} = Option(__v))""".stripMargin
|def $withMethod(__v: ${singleType}): ${message.scalaType.nameSymbol} = copy(${field.scalaName.asSymbol} = _root_.scala.Option(__v))""".stripMargin
)
}
.when(field.isInOneof) { p =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final case class MyContainer(
}
def getMyAny: com.google.protobuf.any.Any = myAny.getOrElse(com.google.protobuf.any.Any.defaultInstance)
def clearMyAny: MyContainer = copy(myAny = _root_.scala.None)
def withMyAny(__v: com.google.protobuf.any.Any): MyContainer = copy(myAny = Option(__v))
def withMyAny(__v: com.google.protobuf.any.Any): MyContainer = copy(myAny = _root_.scala.Option(__v))
def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v)
def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty)
def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final case class MessageContainer(
}
def getOpt: scalapb.perf.protos.SimpleMessage = opt.getOrElse(scalapb.perf.protos.SimpleMessage.defaultInstance)
def clearOpt: MessageContainer = copy(opt = _root_.scala.None)
def withOpt(__v: scalapb.perf.protos.SimpleMessage): MessageContainer = copy(opt = Option(__v))
def withOpt(__v: scalapb.perf.protos.SimpleMessage): MessageContainer = copy(opt = _root_.scala.Option(__v))
def clearRep = copy(rep = _root_.scala.Seq.empty)
def addRep(__vs: scalapb.perf.protos.SimpleMessage *): MessageContainer = addAllRep(__vs)
def addAllRep(__vs: Iterable[scalapb.perf.protos.SimpleMessage]): MessageContainer = copy(rep = rep ++ __vs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ final case class Api(
def withVersion(__v: _root_.scala.Predef.String): Api = copy(version = __v)
def getSourceContext: com.google.protobuf.source_context.SourceContext = sourceContext.getOrElse(com.google.protobuf.source_context.SourceContext.defaultInstance)
def clearSourceContext: Api = copy(sourceContext = _root_.scala.None)
def withSourceContext(__v: com.google.protobuf.source_context.SourceContext): Api = copy(sourceContext = Option(__v))
def withSourceContext(__v: com.google.protobuf.source_context.SourceContext): Api = copy(sourceContext = _root_.scala.Option(__v))
def clearMixins = copy(mixins = _root_.scala.Seq.empty)
def addMixins(__vs: com.google.protobuf.api.Mixin *): Api = addAllMixins(__vs)
def addAllMixins(__vs: Iterable[com.google.protobuf.api.Mixin]): Api = copy(mixins = mixins ++ __vs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final case class CodeGeneratorRequest(
def withFileToGenerate(__v: _root_.scala.Seq[_root_.scala.Predef.String]): CodeGeneratorRequest = copy(fileToGenerate = __v)
def getParameter: _root_.scala.Predef.String = parameter.getOrElse("")
def clearParameter: CodeGeneratorRequest = copy(parameter = _root_.scala.None)
def withParameter(__v: _root_.scala.Predef.String): CodeGeneratorRequest = copy(parameter = Option(__v))
def withParameter(__v: _root_.scala.Predef.String): CodeGeneratorRequest = copy(parameter = _root_.scala.Option(__v))
def clearProtoFile = copy(protoFile = _root_.scala.Seq.empty)
def addProtoFile(__vs: com.google.protobuf.descriptor.FileDescriptorProto *): CodeGeneratorRequest = addAllProtoFile(__vs)
def addAllProtoFile(__vs: Iterable[com.google.protobuf.descriptor.FileDescriptorProto]): CodeGeneratorRequest = copy(protoFile = protoFile ++ __vs)
Expand All @@ -129,7 +129,7 @@ final case class CodeGeneratorRequest(
def withSourceFileDescriptors(__v: _root_.scala.Seq[com.google.protobuf.descriptor.FileDescriptorProto]): CodeGeneratorRequest = copy(sourceFileDescriptors = __v)
def getCompilerVersion: com.google.protobuf.compiler.plugin.Version = compilerVersion.getOrElse(com.google.protobuf.compiler.plugin.Version.defaultInstance)
def clearCompilerVersion: CodeGeneratorRequest = copy(compilerVersion = _root_.scala.None)
def withCompilerVersion(__v: com.google.protobuf.compiler.plugin.Version): CodeGeneratorRequest = copy(compilerVersion = Option(__v))
def withCompilerVersion(__v: com.google.protobuf.compiler.plugin.Version): CodeGeneratorRequest = copy(compilerVersion = _root_.scala.Option(__v))
def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v)
def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty)
def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ final case class CodeGeneratorResponse(
}
def getError: _root_.scala.Predef.String = error.getOrElse("")
def clearError: CodeGeneratorResponse = copy(error = _root_.scala.None)
def withError(__v: _root_.scala.Predef.String): CodeGeneratorResponse = copy(error = Option(__v))
def withError(__v: _root_.scala.Predef.String): CodeGeneratorResponse = copy(error = _root_.scala.Option(__v))
def getSupportedFeatures: _root_.scala.Long = supportedFeatures.getOrElse(0L)
def clearSupportedFeatures: CodeGeneratorResponse = copy(supportedFeatures = _root_.scala.None)
def withSupportedFeatures(__v: _root_.scala.Long): CodeGeneratorResponse = copy(supportedFeatures = Option(__v))
def withSupportedFeatures(__v: _root_.scala.Long): CodeGeneratorResponse = copy(supportedFeatures = _root_.scala.Option(__v))
def getMinimumEdition: _root_.scala.Int = minimumEdition.getOrElse(0)
def clearMinimumEdition: CodeGeneratorResponse = copy(minimumEdition = _root_.scala.None)
def withMinimumEdition(__v: _root_.scala.Int): CodeGeneratorResponse = copy(minimumEdition = Option(__v))
def withMinimumEdition(__v: _root_.scala.Int): CodeGeneratorResponse = copy(minimumEdition = _root_.scala.Option(__v))
def getMaximumEdition: _root_.scala.Int = maximumEdition.getOrElse(0)
def clearMaximumEdition: CodeGeneratorResponse = copy(maximumEdition = _root_.scala.None)
def withMaximumEdition(__v: _root_.scala.Int): CodeGeneratorResponse = copy(maximumEdition = Option(__v))
def withMaximumEdition(__v: _root_.scala.Int): CodeGeneratorResponse = copy(maximumEdition = _root_.scala.Option(__v))
def clearFile = copy(file = _root_.scala.Seq.empty)
def addFile(__vs: com.google.protobuf.compiler.plugin.CodeGeneratorResponse.File *): CodeGeneratorResponse = addAllFile(__vs)
def addAllFile(__vs: Iterable[com.google.protobuf.compiler.plugin.CodeGeneratorResponse.File]): CodeGeneratorResponse = copy(file = file ++ __vs)
Expand Down Expand Up @@ -384,16 +384,16 @@ object CodeGeneratorResponse extends scalapb.GeneratedMessageCompanion[com.googl
}
def getName: _root_.scala.Predef.String = name.getOrElse("")
def clearName: File = copy(name = _root_.scala.None)
def withName(__v: _root_.scala.Predef.String): File = copy(name = Option(__v))
def withName(__v: _root_.scala.Predef.String): File = copy(name = _root_.scala.Option(__v))
def getInsertionPoint: _root_.scala.Predef.String = insertionPoint.getOrElse("")
def clearInsertionPoint: File = copy(insertionPoint = _root_.scala.None)
def withInsertionPoint(__v: _root_.scala.Predef.String): File = copy(insertionPoint = Option(__v))
def withInsertionPoint(__v: _root_.scala.Predef.String): File = copy(insertionPoint = _root_.scala.Option(__v))
def getContent: _root_.scala.Predef.String = content.getOrElse("")
def clearContent: File = copy(content = _root_.scala.None)
def withContent(__v: _root_.scala.Predef.String): File = copy(content = Option(__v))
def withContent(__v: _root_.scala.Predef.String): File = copy(content = _root_.scala.Option(__v))
def getGeneratedCodeInfo: com.google.protobuf.descriptor.GeneratedCodeInfo = generatedCodeInfo.getOrElse(com.google.protobuf.descriptor.GeneratedCodeInfo.defaultInstance)
def clearGeneratedCodeInfo: File = copy(generatedCodeInfo = _root_.scala.None)
def withGeneratedCodeInfo(__v: com.google.protobuf.descriptor.GeneratedCodeInfo): File = copy(generatedCodeInfo = Option(__v))
def withGeneratedCodeInfo(__v: com.google.protobuf.descriptor.GeneratedCodeInfo): File = copy(generatedCodeInfo = _root_.scala.Option(__v))
def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v)
def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty)
def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ final case class Version(
}
def getMajor: _root_.scala.Int = major.getOrElse(0)
def clearMajor: Version = copy(major = _root_.scala.None)
def withMajor(__v: _root_.scala.Int): Version = copy(major = Option(__v))
def withMajor(__v: _root_.scala.Int): Version = copy(major = _root_.scala.Option(__v))
def getMinor: _root_.scala.Int = minor.getOrElse(0)
def clearMinor: Version = copy(minor = _root_.scala.None)
def withMinor(__v: _root_.scala.Int): Version = copy(minor = Option(__v))
def withMinor(__v: _root_.scala.Int): Version = copy(minor = _root_.scala.Option(__v))
def getPatch: _root_.scala.Int = patch.getOrElse(0)
def clearPatch: Version = copy(patch = _root_.scala.None)
def withPatch(__v: _root_.scala.Int): Version = copy(patch = Option(__v))
def withPatch(__v: _root_.scala.Int): Version = copy(patch = _root_.scala.Option(__v))
def getSuffix: _root_.scala.Predef.String = suffix.getOrElse("")
def clearSuffix: Version = copy(suffix = _root_.scala.None)
def withSuffix(__v: _root_.scala.Predef.String): Version = copy(suffix = Option(__v))
def withSuffix(__v: _root_.scala.Predef.String): Version = copy(suffix = _root_.scala.Option(__v))
def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v)
def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty)
def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ final case class DescriptorProto(
}
def getName: _root_.scala.Predef.String = name.getOrElse("")
def clearName: DescriptorProto = copy(name = _root_.scala.None)
def withName(__v: _root_.scala.Predef.String): DescriptorProto = copy(name = Option(__v))
def withName(__v: _root_.scala.Predef.String): DescriptorProto = copy(name = _root_.scala.Option(__v))
def clearField = copy(field = _root_.scala.Seq.empty)
def addField(__vs: com.google.protobuf.descriptor.FieldDescriptorProto *): DescriptorProto = addAllField(__vs)
def addAllField(__vs: Iterable[com.google.protobuf.descriptor.FieldDescriptorProto]): DescriptorProto = copy(field = field ++ __vs)
Expand All @@ -167,7 +167,7 @@ final case class DescriptorProto(
def withOneofDecl(__v: _root_.scala.Seq[com.google.protobuf.descriptor.OneofDescriptorProto]): DescriptorProto = copy(oneofDecl = __v)
def getOptions: com.google.protobuf.descriptor.MessageOptions = options.getOrElse(com.google.protobuf.descriptor.MessageOptions.defaultInstance)
def clearOptions: DescriptorProto = copy(options = _root_.scala.None)
def withOptions(__v: com.google.protobuf.descriptor.MessageOptions): DescriptorProto = copy(options = Option(__v))
def withOptions(__v: com.google.protobuf.descriptor.MessageOptions): DescriptorProto = copy(options = _root_.scala.Option(__v))
def clearReservedRange = copy(reservedRange = _root_.scala.Seq.empty)
def addReservedRange(__vs: com.google.protobuf.descriptor.DescriptorProto.ReservedRange *): DescriptorProto = addAllReservedRange(__vs)
def addAllReservedRange(__vs: Iterable[com.google.protobuf.descriptor.DescriptorProto.ReservedRange]): DescriptorProto = copy(reservedRange = reservedRange ++ __vs)
Expand Down Expand Up @@ -382,13 +382,13 @@ object DescriptorProto extends scalapb.GeneratedMessageCompanion[com.google.prot
}
def getStart: _root_.scala.Int = start.getOrElse(0)
def clearStart: ExtensionRange = copy(start = _root_.scala.None)
def withStart(__v: _root_.scala.Int): ExtensionRange = copy(start = Option(__v))
def withStart(__v: _root_.scala.Int): ExtensionRange = copy(start = _root_.scala.Option(__v))
def getEnd: _root_.scala.Int = end.getOrElse(0)
def clearEnd: ExtensionRange = copy(end = _root_.scala.None)
def withEnd(__v: _root_.scala.Int): ExtensionRange = copy(end = Option(__v))
def withEnd(__v: _root_.scala.Int): ExtensionRange = copy(end = _root_.scala.Option(__v))
def getOptions: com.google.protobuf.descriptor.ExtensionRangeOptions = options.getOrElse(com.google.protobuf.descriptor.ExtensionRangeOptions.defaultInstance)
def clearOptions: ExtensionRange = copy(options = _root_.scala.None)
def withOptions(__v: com.google.protobuf.descriptor.ExtensionRangeOptions): ExtensionRange = copy(options = Option(__v))
def withOptions(__v: com.google.protobuf.descriptor.ExtensionRangeOptions): ExtensionRange = copy(options = _root_.scala.Option(__v))
def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v)
def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty)
def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = {
Expand Down Expand Up @@ -544,10 +544,10 @@ object DescriptorProto extends scalapb.GeneratedMessageCompanion[com.google.prot
}
def getStart: _root_.scala.Int = start.getOrElse(0)
def clearStart: ReservedRange = copy(start = _root_.scala.None)
def withStart(__v: _root_.scala.Int): ReservedRange = copy(start = Option(__v))
def withStart(__v: _root_.scala.Int): ReservedRange = copy(start = _root_.scala.Option(__v))
def getEnd: _root_.scala.Int = end.getOrElse(0)
def clearEnd: ReservedRange = copy(end = _root_.scala.None)
def withEnd(__v: _root_.scala.Int): ReservedRange = copy(end = Option(__v))
def withEnd(__v: _root_.scala.Int): ReservedRange = copy(end = _root_.scala.Option(__v))
def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v)
def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty)
def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ final case class EnumDescriptorProto(
}
def getName: _root_.scala.Predef.String = name.getOrElse("")
def clearName: EnumDescriptorProto = copy(name = _root_.scala.None)
def withName(__v: _root_.scala.Predef.String): EnumDescriptorProto = copy(name = Option(__v))
def withName(__v: _root_.scala.Predef.String): EnumDescriptorProto = copy(name = _root_.scala.Option(__v))
def clearValue = copy(value = _root_.scala.Seq.empty)
def addValue(__vs: com.google.protobuf.descriptor.EnumValueDescriptorProto *): EnumDescriptorProto = addAllValue(__vs)
def addAllValue(__vs: Iterable[com.google.protobuf.descriptor.EnumValueDescriptorProto]): EnumDescriptorProto = copy(value = value ++ __vs)
def withValue(__v: _root_.scala.Seq[com.google.protobuf.descriptor.EnumValueDescriptorProto]): EnumDescriptorProto = copy(value = __v)
def getOptions: com.google.protobuf.descriptor.EnumOptions = options.getOrElse(com.google.protobuf.descriptor.EnumOptions.defaultInstance)
def clearOptions: EnumDescriptorProto = copy(options = _root_.scala.None)
def withOptions(__v: com.google.protobuf.descriptor.EnumOptions): EnumDescriptorProto = copy(options = Option(__v))
def withOptions(__v: com.google.protobuf.descriptor.EnumOptions): EnumDescriptorProto = copy(options = _root_.scala.Option(__v))
def clearReservedRange = copy(reservedRange = _root_.scala.Seq.empty)
def addReservedRange(__vs: com.google.protobuf.descriptor.EnumDescriptorProto.EnumReservedRange *): EnumDescriptorProto = addAllReservedRange(__vs)
def addAllReservedRange(__vs: Iterable[com.google.protobuf.descriptor.EnumDescriptorProto.EnumReservedRange]): EnumDescriptorProto = copy(reservedRange = reservedRange ++ __vs)
Expand Down Expand Up @@ -261,10 +261,10 @@ object EnumDescriptorProto extends scalapb.GeneratedMessageCompanion[com.google.
}
def getStart: _root_.scala.Int = start.getOrElse(0)
def clearStart: EnumReservedRange = copy(start = _root_.scala.None)
def withStart(__v: _root_.scala.Int): EnumReservedRange = copy(start = Option(__v))
def withStart(__v: _root_.scala.Int): EnumReservedRange = copy(start = _root_.scala.Option(__v))
def getEnd: _root_.scala.Int = end.getOrElse(0)
def clearEnd: EnumReservedRange = copy(end = _root_.scala.None)
def withEnd(__v: _root_.scala.Int): EnumReservedRange = copy(end = Option(__v))
def withEnd(__v: _root_.scala.Int): EnumReservedRange = copy(end = _root_.scala.Option(__v))
def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v)
def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty)
def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@ final case class EnumOptions(
}
def getAllowAlias: _root_.scala.Boolean = allowAlias.getOrElse(false)
def clearAllowAlias: EnumOptions = copy(allowAlias = _root_.scala.None)
def withAllowAlias(__v: _root_.scala.Boolean): EnumOptions = copy(allowAlias = Option(__v))
def withAllowAlias(__v: _root_.scala.Boolean): EnumOptions = copy(allowAlias = _root_.scala.Option(__v))
def getDeprecated: _root_.scala.Boolean = deprecated.getOrElse(false)
def clearDeprecated: EnumOptions = copy(deprecated = _root_.scala.None)
def withDeprecated(__v: _root_.scala.Boolean): EnumOptions = copy(deprecated = Option(__v))
def withDeprecated(__v: _root_.scala.Boolean): EnumOptions = copy(deprecated = _root_.scala.Option(__v))
def getDeprecatedLegacyJsonFieldConflicts: _root_.scala.Boolean = deprecatedLegacyJsonFieldConflicts.getOrElse(false)
def clearDeprecatedLegacyJsonFieldConflicts: EnumOptions = copy(deprecatedLegacyJsonFieldConflicts = _root_.scala.None)
def withDeprecatedLegacyJsonFieldConflicts(__v: _root_.scala.Boolean): EnumOptions = copy(deprecatedLegacyJsonFieldConflicts = Option(__v))
def withDeprecatedLegacyJsonFieldConflicts(__v: _root_.scala.Boolean): EnumOptions = copy(deprecatedLegacyJsonFieldConflicts = _root_.scala.Option(__v))
def getFeatures: com.google.protobuf.descriptor.FeatureSet = features.getOrElse(com.google.protobuf.descriptor.FeatureSet.defaultInstance)
def clearFeatures: EnumOptions = copy(features = _root_.scala.None)
def withFeatures(__v: com.google.protobuf.descriptor.FeatureSet): EnumOptions = copy(features = Option(__v))
def withFeatures(__v: com.google.protobuf.descriptor.FeatureSet): EnumOptions = copy(features = _root_.scala.Option(__v))
def clearUninterpretedOption = copy(uninterpretedOption = _root_.scala.Seq.empty)
def addUninterpretedOption(__vs: com.google.protobuf.descriptor.UninterpretedOption *): EnumOptions = addAllUninterpretedOption(__vs)
def addAllUninterpretedOption(__vs: Iterable[com.google.protobuf.descriptor.UninterpretedOption]): EnumOptions = copy(uninterpretedOption = uninterpretedOption ++ __vs)
Expand Down
Loading

0 comments on commit f422f2e

Please sign in to comment.