Skip to content

Commit 178a0d4

Browse files
jakehschwartzrozza
authored andcommitted
Include default match statement to CaseClassCodec macro
Also add compile warnings to the build. JAVA-4319
1 parent e557fc4 commit 178a0d4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

bson-scala/src/main/scala/org/mongodb/scala/bson/codecs/macrocodecs/CaseClassCodec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ private[codecs] object CaseClassCodec {
350350
val instanceValue = value.asInstanceOf[${classType}]
351351
..${writeClassValues(fields, ignoredFields(classType))}"""
352352
}.toSeq
353-
}
353+
} :+ cq"""_ => throw new BsonInvalidOperationException("Unexpected class type: " + className)"""
354354
q"""
355355
writer.writeStartDocument()
356356
this.writeClassFieldName(writer, className, encoderContext)

build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ configure(scalaProjects) {
128128

129129
tasks.withType(ScalaCompile) {
130130
scalaCompileOptions.deprecation = false
131+
if(scalaVersion.startsWith("2.13")) {
132+
scalaCompileOptions.additionalParameters = [
133+
"-feature",
134+
"-unchecked",
135+
"-language:reflectiveCalls",
136+
"-Wconf:cat=deprecation:ws,any:e",
137+
"-Xlint:strict-unsealed-patmat"
138+
]
139+
}
131140
}
132141

133142
tasks.withType(GenerateModuleMetadata) {

0 commit comments

Comments
 (0)