Skip to content

Commit

Permalink
Suppress unused value warning, avoid inferred Any (also unused)
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Jun 19, 2023
1 parent 491c4ce commit 3711f7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 1 addition & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ 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[IncompatibleResultTypeProblem]("scalapb.UnknownFieldSet#Builder.parseField"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scalapb.UnknownFieldSet#Field#Builder.parseField"),
ProblemFilters.exclude[FinalMethodProblem]("*.parseFrom")
)
)
.jvmPlatform(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,20 @@ private[compiler] class ParseFromGenerator(
} else p
}
.when(!message.preservesUnknownFields)(
_.add(" case tag => _input__.skipField(tag): Unit")
_.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
5 changes: 2 additions & 3 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): this.type = {
def parseField(tag: Int, input: CodedInputStream) = {
val wireType = WireType.getTagWireType(tag)

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

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

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

0 comments on commit 3711f7e

Please sign in to comment.