diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-06-10 17:21:55 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-06-10 17:21:55 +0200 |
commit | 1ed2031c3e0c342f4aa249dc16970c9e42dbe33f (patch) | |
tree | 64fe0b0f7e0f2734fc317a3a1a1fbf895eb63a32 /src | |
parent | ad9d87b1faad22c1a2e05351757c0a940e2a0ef2 (diff) | |
download | scala-1ed2031c3e0c342f4aa249dc16970c9e42dbe33f.tar.gz scala-1ed2031c3e0c342f4aa249dc16970c9e42dbe33f.tar.bz2 scala-1ed2031c3e0c342f4aa249dc16970c9e42dbe33f.zip |
Refactor `enumerateSubtypes`
- reorder to make "unenumerable" the last case
- reunite an orphaned comment with its loved ones.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala index 3ef9b8c0b4..13c7a0996a 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala @@ -104,7 +104,6 @@ trait TreeAndTypeAnalysis extends Debugging { // TODO case _ if tp.isTupleType => // recurse into component types case modSym: ModuleClassSymbol => Some(List(tp)) - // make sure it's not a primitive, else (5: Byte) match { case 5 => ... } sees no Byte case sym: RefinementClassSymbol => val parentSubtypes: List[Option[List[Type]]] = tp.parents.map(parent => enumerateSubtypes(parent)) if (parentSubtypes exists (_.isDefined)) @@ -115,10 +114,8 @@ trait TreeAndTypeAnalysis extends Debugging { parentSubtypes flatMap (_.getOrElse(Nil)) filter (_ <:< tp) ) else None - case sym if !sym.isSealed || isPrimitiveValueClass(sym) => - debug.patmat("enum unsealed "+ ((tp, sym, sym.isSealed, isPrimitiveValueClass(sym)))) - None - case sym => + // make sure it's not a primitive, else (5: Byte) match { case 5 => ... } sees no Byte + case sym if sym.isSealed && !isPrimitiveValueClass(sym) => val subclasses = debug.patmatResult(s"enum $sym sealed, subclasses")( // symbols which are both sealed and abstract need not be covered themselves, because // all of their children must be and they cannot otherwise be created. @@ -146,6 +143,9 @@ trait TreeAndTypeAnalysis extends Debugging { else None } }) + case sym => + debug.patmat("enum unsealed "+ ((tp, sym, sym.isSealed, isPrimitiveValueClass(sym)))) + None } // approximate a type to the static type that is fully checkable at run time, |