Skip to content

Commit 750892d

Browse files
committed
Fixing exhaustiveness warnings.
ClassfileAnnotArg becoming sealed brought tidings of not being exhaustive.
1 parent 9761d22 commit 750892d

File tree

6 files changed

+18
-24
lines changed

6 files changed

+18
-24
lines changed

src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ trait GenAnnotationInfos {
4545
mirrorFactoryCall(nme.ArrayAnnotArg, scalaFactoryCall(nme.Array, args map reifyClassfileAnnotArg: _*))
4646
case NestedAnnotArg(ann) =>
4747
mirrorFactoryCall(nme.NestedAnnotArg, reifyAnnotationInfo(ann))
48+
case _ =>
49+
sys.error(s"Don't know what to do with $arg")
4850
}
4951

5052
// if you reify originals of anns, you get SO when trying to reify AnnotatedTypes, so screw it - after all, it's not that important

src/compiler/scala/reflect/reify/phases/Reshape.scala

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,10 @@ trait Reshape {
231231
val args = if (ann.assocs.isEmpty) {
232232
ann.args
233233
} else {
234-
def toScalaAnnotation(jann: ClassfileAnnotArg): Tree = jann match {
235-
case LiteralAnnotArg(const) =>
236-
Literal(const)
237-
case ArrayAnnotArg(arr) =>
238-
Apply(Ident(definitions.ArrayModule), arr.toList map toScalaAnnotation)
239-
case NestedAnnotArg(ann) =>
240-
toPreTyperAnnotation(ann)
234+
def toScalaAnnotation(jann: ClassfileAnnotArg): Tree = (jann: @unchecked) match {
235+
case LiteralAnnotArg(const) => Literal(const)
236+
case ArrayAnnotArg(arr) => Apply(Ident(definitions.ArrayModule), arr.toList map toScalaAnnotation)
237+
case NestedAnnotArg(ann) => toPreTyperAnnotation(ann)
241238
}
242239

243240
ann.assocs map { case (nme, arg) => AssignOrNamedArg(Ident(nme), toScalaAnnotation(arg)) }

src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
654654
def emitArgument(av: asm.AnnotationVisitor,
655655
name: String,
656656
arg: ClassfileAnnotArg) {
657-
arg match {
657+
(arg: @unchecked) match {
658658

659659
case LiteralAnnotArg(const) =>
660660
if (const.isNonUnitAnyVal) { av.visit(name, const.value) }

src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
932932
def emitArgument(av: asm.AnnotationVisitor,
933933
name: String,
934934
arg: ClassfileAnnotArg) {
935-
arg match {
935+
(arg: @unchecked) match {
936936

937937
case LiteralAnnotArg(const) =>
938938
if(const.isNonUnitAnyVal) { av.visit(name, const.value) }

src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -486,14 +486,10 @@ abstract class Pickler extends SubComponent {
486486
}
487487
}
488488
def putClassfileAnnotArg(carg: ClassfileAnnotArg) {
489-
carg match {
490-
case LiteralAnnotArg(const) =>
491-
putConstant(const)
492-
case ArrayAnnotArg(args) =>
493-
if (putEntry(carg))
494-
args foreach putClassfileAnnotArg
495-
case NestedAnnotArg(annInfo) =>
496-
putAnnotation(annInfo)
489+
(carg: @unchecked) match {
490+
case LiteralAnnotArg(const) => putConstant(const)
491+
case ArrayAnnotArg(args) => if (putEntry(carg)) args foreach putClassfileAnnotArg
492+
case NestedAnnotArg(annInfo) => putAnnotation(annInfo)
497493
}
498494
}
499495
val AnnotationInfo(tpe, args, assocs) = annot
@@ -559,13 +555,10 @@ abstract class Pickler extends SubComponent {
559555

560556
/** Write a ClassfileAnnotArg (argument to classfile annotation) */
561557
def writeClassfileAnnotArg(carg: ClassfileAnnotArg) {
562-
carg match {
563-
case LiteralAnnotArg(const) =>
564-
writeRef(const)
565-
case ArrayAnnotArg(args) =>
566-
writeRef(carg)
567-
case NestedAnnotArg(annInfo) =>
568-
writeRef(annInfo)
558+
(carg: @unchecked) match {
559+
case LiteralAnnotArg(const) => writeRef(const)
560+
case ArrayAnnotArg(args) => writeRef(carg)
561+
case NestedAnnotArg(annInfo) => writeRef(annInfo)
569562
}
570563
}
571564

src/reflect/scala/reflect/internal/Importers.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ trait Importers extends api.Importers { to: SymbolTable =>
434434
ScalaSigBytes(bytes)
435435
case from.NestedAnnotArg(annInfo) =>
436436
NestedAnnotArg(importAnnotationInfo(annInfo))
437+
case from.UnmappableAnnotArg =>
438+
UnmappableAnnotArg
437439
}
438440

439441
// todo. careful import of positions

0 commit comments

Comments
 (0)