Skip to content

Commit 491c4ce

Browse files
committed
Avoid warnings about unused values
1 parent ff676c1 commit 491c4ce

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

build.sbt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ 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")
70+
ProblemFilters.exclude[FinalMethodProblem]("*.parseFrom"),
71+
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scalapb.UnknownFieldSet#Builder.parseField"),
72+
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scalapb.UnknownFieldSet#Field#Builder.parseField"),
7173
)
7274
)
7375
.jvmPlatform(
@@ -381,13 +383,14 @@ lazy val e2e = (projectMatrix in file("e2e"))
381383
)
382384
.settings(e2eCommonSettings)
383385
.settings(
384-
scalacOptions ++= (if (!isScala3.value)
386+
Compile / scalacOptions ++= (if (!isScala3.value)
385387
Seq(
386388
"-P:silencer:globalFilters=value deprecatedInt32 in class TestDeprecatedFields is deprecated",
387389
"-P:silencer:pathFilters=custom_options_use;CustomAnnotationProto.scala;TestDeprecatedFields.scala",
388390
"-P:silencer:lineContentFilters=import com.thesamet.pb.MisplacedMapper.weatherMapper"
389-
)
391+
) ++ (if (scalaVersion.value.startsWith("2.13")) Seq("-Wnonunit-statement", "-Xlint") else Nil)
390392
else Nil),
393+
Test / scalacOptions ++= (if (scalaVersion.value.startsWith("2.13")) Seq("-Wnonunit-statement:false", "-Xlint:-multiarg-infix") else Nil),
391394
PB.protocVersion := versions.protobuf,
392395
Compile / PB.protocOptions += "--experimental_allow_proto3_optional",
393396
Compile / PB.targets := Seq(

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ private[compiler] class ParseFromGenerator(
212212
| }""".stripMargin)
213213
} else p
214214
}
215-
.when(!message.preservesUnknownFields)(_.add(" case tag => _input__.skipField(tag)"))
215+
.when(!message.preservesUnknownFields)(
216+
_.add(" case tag => _input__.skipField(tag): Unit")
217+
)
216218
.when(message.preservesUnknownFields)(
217219
_.add(
218220
""" case tag =>

proptest/src/test/scala/GenTypes.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ object GenTypes {
6868
def packable = false
6969
def isMap = false
7070
}
71+
object MessageReference extends (Int => ProtoType)
7172

7273
case class EnumReference(id: Int) extends ProtoType {
7374
def packable = true
7475
def isMap = false
7576
}
77+
object EnumReference extends (Int => ProtoType)
7678

7779
case class MapType(keyType: ProtoType, valueType: ProtoType) extends ProtoType {
7880
def packable = false

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

Lines changed: 4 additions & 2 deletions
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) = {
92+
def parseField(tag: Int, input: CodedInputStream): this.type = {
9393
val wireType = WireType.getTagWireType(tag)
9494

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

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

138-
def parseField(tag: Int, input: CodedInputStream) = {
139+
def parseField(tag: Int, input: CodedInputStream): this.type = {
139140
val fieldNumber = WireType.getTagFieldNumber(tag)
140141
fieldBuilders.getOrElseUpdate(fieldNumber, new Field.Builder()).parseField(tag, input)
142+
this
141143
}
142144
}
143145
}

0 commit comments

Comments
 (0)