Skip to content

Commit 7c3a4a6

Browse files
committed
Suppress unused value warning, avoid inferred Any (also unused)
1 parent 491c4ce commit 7c3a4a6

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

build.sbt

+1-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ lazy val runtime = (projectMatrix in file("scalapb-runtime"))
6767
ProblemFilters.exclude[ReversedMissingMethodProblem]("scalapb.GeneratedEnum.asRecognized"),
6868
ProblemFilters.exclude[InheritedNewAbstractMethodProblem]("*Extension*"),
6969
ProblemFilters.exclude[Problem]("scalapb.options.*"),
70-
ProblemFilters.exclude[FinalMethodProblem]("*.parseFrom"),
71-
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scalapb.UnknownFieldSet#Builder.parseField"),
72-
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scalapb.UnknownFieldSet#Field#Builder.parseField"),
70+
ProblemFilters.exclude[FinalMethodProblem]("*.parseFrom")
7371
)
7472
)
7573
.jvmPlatform(

compiler-plugin/src/main/scala/scalapb/compiler/ParseFromGenerator.scala

+7-2
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,20 @@ private[compiler] class ParseFromGenerator(
213213
} else p
214214
}
215215
.when(!message.preservesUnknownFields)(
216-
_.add(" case tag => _input__.skipField(tag): Unit")
216+
_.add(
217+
"""| case tag =>
218+
| _input__.skipField(tag): @_root_.scala.annotation.nowarn
219+
| ()""".stripMargin
220+
)
217221
)
218222
.when(message.preservesUnknownFields)(
219223
_.add(
220224
""" case tag =>
221225
| if (_unknownFields__ == null) {
222226
| _unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
223227
| }
224-
| _unknownFields__.parseField(tag, _input__)""".stripMargin
228+
| _unknownFields__.parseField(tag, _input__): @_root_.scala.annotation.nowarn
229+
| ()""".stripMargin
225230
)
226231
)
227232
.add(" }")

scalapb-runtime/src/main/scala/scalapb/UnknownFieldSet.scala

+2-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ object UnknownFieldSet {
8989
lengthDelimited = lengthDelimited.result()
9090
)
9191

92-
def parseField(tag: Int, input: CodedInputStream): this.type = {
92+
def parseField(tag: Int, input: CodedInputStream) = {
9393
val wireType = WireType.getTagWireType(tag)
9494

9595
wireType match {
@@ -106,7 +106,6 @@ object UnknownFieldSet {
106106
s"Protocol message tag had invalid wire type: ${wireType}"
107107
)
108108
}
109-
this
110109
}
111110
}
112111

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

139-
def parseField(tag: Int, input: CodedInputStream): this.type = {
138+
def parseField(tag: Int, input: CodedInputStream) = {
140139
val fieldNumber = WireType.getTagFieldNumber(tag)
141140
fieldBuilders.getOrElseUpdate(fieldNumber, new Field.Builder()).parseField(tag, input)
142-
this
143141
}
144142
}
145143
}

0 commit comments

Comments
 (0)