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 1 commit
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
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 = {
som-snytt marked this conversation as resolved.
Show resolved Hide resolved
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