From 750892d4d3e155f1f14a9694151e9ac33f6dc3ff Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 17 Jul 2013 12:57:30 -0700 Subject: Fixing exhaustiveness warnings. ClassfileAnnotArg becoming sealed brought tidings of not being exhaustive. --- .../reflect/reify/codegen/GenAnnotationInfos.scala | 2 ++ .../scala/reflect/reify/phases/Reshape.scala | 11 ++++------- .../scala/tools/nsc/backend/jvm/BCodeHelpers.scala | 2 +- .../scala/tools/nsc/backend/jvm/GenASM.scala | 2 +- .../scala/tools/nsc/symtab/classfile/Pickler.scala | 23 ++++++++-------------- src/reflect/scala/reflect/internal/Importers.scala | 2 ++ 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala b/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala index 5a454e1e07..bd60faf4cd 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala @@ -45,6 +45,8 @@ trait GenAnnotationInfos { mirrorFactoryCall(nme.ArrayAnnotArg, scalaFactoryCall(nme.Array, args map reifyClassfileAnnotArg: _*)) case NestedAnnotArg(ann) => mirrorFactoryCall(nme.NestedAnnotArg, reifyAnnotationInfo(ann)) + case _ => + sys.error(s"Don't know what to do with $arg") } // if you reify originals of anns, you get SO when trying to reify AnnotatedTypes, so screw it - after all, it's not that important diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index 5f53f558b4..ae4a03d232 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -231,13 +231,10 @@ trait Reshape { val args = if (ann.assocs.isEmpty) { ann.args } else { - def toScalaAnnotation(jann: ClassfileAnnotArg): Tree = jann match { - case LiteralAnnotArg(const) => - Literal(const) - case ArrayAnnotArg(arr) => - Apply(Ident(definitions.ArrayModule), arr.toList map toScalaAnnotation) - case NestedAnnotArg(ann) => - toPreTyperAnnotation(ann) + def toScalaAnnotation(jann: ClassfileAnnotArg): Tree = (jann: @unchecked) match { + case LiteralAnnotArg(const) => Literal(const) + case ArrayAnnotArg(arr) => Apply(Ident(definitions.ArrayModule), arr.toList map toScalaAnnotation) + case NestedAnnotArg(ann) => toPreTyperAnnotation(ann) } ann.assocs map { case (nme, arg) => AssignOrNamedArg(Ident(nme), toScalaAnnotation(arg)) } diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala index 62270b7c0a..182209dfe6 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala @@ -654,7 +654,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { def emitArgument(av: asm.AnnotationVisitor, name: String, arg: ClassfileAnnotArg) { - arg match { + (arg: @unchecked) match { case LiteralAnnotArg(const) => if (const.isNonUnitAnyVal) { av.visit(name, const.value) } diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index ea2cbbe3d3..4cb2f514ec 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -932,7 +932,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { def emitArgument(av: asm.AnnotationVisitor, name: String, arg: ClassfileAnnotArg) { - arg match { + (arg: @unchecked) match { case LiteralAnnotArg(const) => if(const.isNonUnitAnyVal) { av.visit(name, const.value) } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 3265af9f5b..9bad29097c 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -486,14 +486,10 @@ abstract class Pickler extends SubComponent { } } def putClassfileAnnotArg(carg: ClassfileAnnotArg) { - carg match { - case LiteralAnnotArg(const) => - putConstant(const) - case ArrayAnnotArg(args) => - if (putEntry(carg)) - args foreach putClassfileAnnotArg - case NestedAnnotArg(annInfo) => - putAnnotation(annInfo) + (carg: @unchecked) match { + case LiteralAnnotArg(const) => putConstant(const) + case ArrayAnnotArg(args) => if (putEntry(carg)) args foreach putClassfileAnnotArg + case NestedAnnotArg(annInfo) => putAnnotation(annInfo) } } val AnnotationInfo(tpe, args, assocs) = annot @@ -559,13 +555,10 @@ abstract class Pickler extends SubComponent { /** Write a ClassfileAnnotArg (argument to classfile annotation) */ def writeClassfileAnnotArg(carg: ClassfileAnnotArg) { - carg match { - case LiteralAnnotArg(const) => - writeRef(const) - case ArrayAnnotArg(args) => - writeRef(carg) - case NestedAnnotArg(annInfo) => - writeRef(annInfo) + (carg: @unchecked) match { + case LiteralAnnotArg(const) => writeRef(const) + case ArrayAnnotArg(args) => writeRef(carg) + case NestedAnnotArg(annInfo) => writeRef(annInfo) } } diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala index f8584ac9b0..b0828e9c54 100644 --- a/src/reflect/scala/reflect/internal/Importers.scala +++ b/src/reflect/scala/reflect/internal/Importers.scala @@ -434,6 +434,8 @@ trait Importers extends api.Importers { to: SymbolTable => ScalaSigBytes(bytes) case from.NestedAnnotArg(annInfo) => NestedAnnotArg(importAnnotationInfo(annInfo)) + case from.UnmappableAnnotArg => + UnmappableAnnotArg } // todo. careful import of positions -- cgit v1.2.3