Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid warnings about unused values #1525

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,14 @@ lazy val e2e = (projectMatrix in file("e2e"))
)
.settings(e2eCommonSettings)
.settings(
scalacOptions ++= (if (!isScala3.value)
Compile / scalacOptions ++= (if (!isScala3.value)
Seq(
"-P:silencer:globalFilters=value deprecatedInt32 in class TestDeprecatedFields is deprecated",
"-P:silencer:pathFilters=custom_options_use;CustomAnnotationProto.scala;TestDeprecatedFields.scala",
"-P:silencer:lineContentFilters=import com.thesamet.pb.MisplacedMapper.weatherMapper"
)
) ++ (if (scalaVersion.value.startsWith("2.13")) Seq("-Wnonunit-statement", "-Xlint") else Nil)
else Nil),
Test / scalacOptions ++= (if (scalaVersion.value.startsWith("2.13")) Seq("-Wnonunit-statement:false", "-Xlint:-multiarg-infix") else Nil),
PB.protocVersion := versions.protobuf,
Compile / PB.protocOptions += "--experimental_allow_proto3_optional",
Compile / PB.targets := Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,21 @@ private[compiler] class ParseFromGenerator(
| }""".stripMargin)
} else p
}
.when(!message.preservesUnknownFields)(_.add(" case tag => _input__.skipField(tag)"))
.when(!message.preservesUnknownFields)(
_.add(
"""| case tag =>
| _input__.skipField(tag): @_root_.scala.annotation.nowarn
| ()""".stripMargin
)
)
.when(message.preservesUnknownFields)(
_.add(
""" case tag =>
| if (_unknownFields__ == null) {
| _unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
| }
| _unknownFields__.parseField(tag, _input__)""".stripMargin
| _unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
| ()""".stripMargin
)
)
.add(" }")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ object MyContainer extends scalapb.GeneratedMessageCompanion[com.thesamet.docs.j
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.thesamet.docs.json.MyContainer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ object MyMessage extends scalapb.GeneratedMessageCompanion[com.thesamet.docs.jso
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.thesamet.docs.json.MyMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ object Duration extends scalapb.GeneratedMessageCompanion[mytypes.duration.Durat
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
mytypes.duration.Duration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ object Person extends scalapb.GeneratedMessageCompanion[scalapb.docs.person.Pers
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
scalapb.docs.person.Person(
Expand Down Expand Up @@ -321,7 +322,8 @@ object Person extends scalapb.GeneratedMessageCompanion[scalapb.docs.person.Pers
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
scalapb.docs.person.Person.Address(
Expand Down
3 changes: 2 additions & 1 deletion docs/src/main/scala/generated/scalapb/perf/protos/Enum.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ object Enum extends scalapb.GeneratedMessageCompanion[scalapb.perf.protos.Enum]
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
scalapb.perf.protos.Enum(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ object EnumVector extends scalapb.GeneratedMessageCompanion[scalapb.perf.protos.
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
scalapb.perf.protos.EnumVector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ object IntVector extends scalapb.GeneratedMessageCompanion[scalapb.perf.protos.I
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
scalapb.perf.protos.IntVector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ object MessageContainer extends scalapb.GeneratedMessageCompanion[scalapb.perf.p
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
scalapb.perf.protos.MessageContainer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ object SimpleMessage extends scalapb.GeneratedMessageCompanion[scalapb.perf.prot
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
scalapb.perf.protos.SimpleMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ object StringMessage extends scalapb.GeneratedMessageCompanion[scalapb.perf.prot
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
scalapb.perf.protos.StringMessage(
Expand Down
2 changes: 2 additions & 0 deletions proptest/src/test/scala/GenTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ object GenTypes {
def packable = false
def isMap = false
}
object MessageReference extends (Int => ProtoType)

case class EnumReference(id: Int) extends ProtoType {
def packable = true
def isMap = false
}
object EnumReference extends (Int => ProtoType)

case class MapType(keyType: ProtoType, valueType: ProtoType) extends ProtoType {
def packable = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ object Any extends scalapb.GeneratedMessageCompanion[com.google.protobuf.any.Any
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.any.Any(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ object Api extends scalapb.GeneratedMessageCompanion[com.google.protobuf.api.Api
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.api.Api(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ object Method extends scalapb.GeneratedMessageCompanion[com.google.protobuf.api.
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.api.Method(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ object Mixin extends scalapb.GeneratedMessageCompanion[com.google.protobuf.api.M
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.api.Mixin(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ object CodeGeneratorRequest extends scalapb.GeneratedMessageCompanion[com.google
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.compiler.plugin.CodeGeneratorRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ object CodeGeneratorResponse extends scalapb.GeneratedMessageCompanion[com.googl
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.compiler.plugin.CodeGeneratorResponse(
Expand Down Expand Up @@ -363,7 +364,8 @@ object CodeGeneratorResponse extends scalapb.GeneratedMessageCompanion[com.googl
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.compiler.plugin.CodeGeneratorResponse.File(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ object Version extends scalapb.GeneratedMessageCompanion[com.google.protobuf.com
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.compiler.plugin.Version(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ object DescriptorProto extends scalapb.GeneratedMessageCompanion[com.google.prot
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.DescriptorProto(
Expand Down Expand Up @@ -435,7 +436,8 @@ object DescriptorProto extends scalapb.GeneratedMessageCompanion[com.google.prot
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.DescriptorProto.ExtensionRange(
Expand Down Expand Up @@ -589,7 +591,8 @@ object DescriptorProto extends scalapb.GeneratedMessageCompanion[com.google.prot
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.DescriptorProto.ReservedRange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ object EnumDescriptorProto extends scalapb.GeneratedMessageCompanion[com.google.
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.EnumDescriptorProto(
Expand Down Expand Up @@ -306,7 +307,8 @@ object EnumDescriptorProto extends scalapb.GeneratedMessageCompanion[com.google.
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.EnumDescriptorProto.EnumReservedRange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ object EnumOptions extends scalapb.GeneratedMessageCompanion[com.google.protobuf
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.EnumOptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ object EnumValueDescriptorProto extends scalapb.GeneratedMessageCompanion[com.go
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.EnumValueDescriptorProto(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ object EnumValueOptions extends scalapb.GeneratedMessageCompanion[com.google.pro
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.EnumValueOptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ object ExtensionRangeOptions extends scalapb.GeneratedMessageCompanion[com.googl
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.ExtensionRangeOptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ object FieldDescriptorProto extends scalapb.GeneratedMessageCompanion[com.google
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.FieldDescriptorProto(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ object FieldOptions extends scalapb.GeneratedMessageCompanion[com.google.protobu
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.FieldOptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ object FileDescriptorProto extends scalapb.GeneratedMessageCompanion[com.google.
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.FileDescriptorProto(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ object FileDescriptorSet extends scalapb.GeneratedMessageCompanion[com.google.pr
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.FileDescriptorSet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ object FileOptions extends scalapb.GeneratedMessageCompanion[com.google.protobuf
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
_unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
()
}
}
com.google.protobuf.descriptor.FileOptions(
Expand Down
Loading