Permalink
Browse files

use Constant::isIntRange even if it's NIH

  • Loading branch information...
1 parent a6b34b6 commit ce563164a3e64d8a7a5ca1f49dd62377d603b5d9 @adriaanm adriaanm committed Jan 16, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
@@ -3497,7 +3497,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// Constant folding sets the type of a constant tree to `ConstantType(Constant(folded))`
// The tree itself can be a literal, an ident, a selection, ...
object SwitchablePattern { def unapply(pat: Tree): Option[Tree] = pat.tpe match {
- case ConstantType(const@Constant((_: Byte ) | (_: Short) | (_: Int ) | (_: Char ))) =>
+ case ConstantType(const) if const.isIntRange =>
Some(Literal(Constant(const.intValue))) // TODO: Java 7 allows strings in switches
case _ => None
}}

0 comments on commit ce56316

Please sign in to comment.