Skip to content

Commit

Permalink
Avoid warnings about unused values
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Jun 6, 2023
1 parent ff676c1 commit 491c4ce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
9 changes: 6 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ lazy val runtime = (projectMatrix in file("scalapb-runtime"))
ProblemFilters.exclude[ReversedMissingMethodProblem]("scalapb.GeneratedEnum.asRecognized"),
ProblemFilters.exclude[InheritedNewAbstractMethodProblem]("*Extension*"),
ProblemFilters.exclude[Problem]("scalapb.options.*"),
ProblemFilters.exclude[FinalMethodProblem]("*.parseFrom")
ProblemFilters.exclude[FinalMethodProblem]("*.parseFrom"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scalapb.UnknownFieldSet#Builder.parseField"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scalapb.UnknownFieldSet#Field#Builder.parseField"),
)
)
.jvmPlatform(
Expand Down Expand Up @@ -381,13 +383,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,7 +212,9 @@ 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): Unit")
)
.when(message.preservesUnknownFields)(
_.add(
""" case tag =>
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
6 changes: 4 additions & 2 deletions scalapb-runtime/src/main/scala/scalapb/UnknownFieldSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ object UnknownFieldSet {
lengthDelimited = lengthDelimited.result()
)

def parseField(tag: Int, input: CodedInputStream) = {
def parseField(tag: Int, input: CodedInputStream): this.type = {
val wireType = WireType.getTagWireType(tag)

wireType match {
Expand All @@ -106,6 +106,7 @@ object UnknownFieldSet {
s"Protocol message tag had invalid wire type: ${wireType}"
)
}
this
}
}

Expand Down Expand Up @@ -135,9 +136,10 @@ object UnknownFieldSet {
if (fieldBuilders.isEmpty) UnknownFieldSet.empty
else new UnknownFieldSet(fieldBuilders.view.mapValues(_.result()).toMap)

def parseField(tag: Int, input: CodedInputStream) = {
def parseField(tag: Int, input: CodedInputStream): this.type = {
val fieldNumber = WireType.getTagFieldNumber(tag)
fieldBuilders.getOrElseUpdate(fieldNumber, new Field.Builder()).parseField(tag, input)
this
}
}
}
Expand Down

0 comments on commit 491c4ce

Please sign in to comment.