diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-06-11 17:56:29 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-06-26 20:17:57 +0200 |
commit | 3601b34fb7bbd60f6f25d3bf44edc653aa7ba45b (patch) | |
tree | 966754efb7b7053f70a34ae7a868540cf4bfd8e4 /src | |
parent | 4da95609a92f0c685bb7a48688fe9c485f2bc328 (diff) | |
download | scala-3601b34fb7bbd60f6f25d3bf44edc653aa7ba45b.tar.gz scala-3601b34fb7bbd60f6f25d3bf44edc653aa7ba45b.tar.bz2 scala-3601b34fb7bbd60f6f25d3bf44edc653aa7ba45b.zip |
exhaust unit: consider Unit as sealed
one of the most boring sealed types imaginable, but a sealed type all the same
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala index 7bac0dac3a..2ee3570905 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala @@ -2350,16 +2350,19 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL // exhaustivity - // make sure it's not a primitive, else (5: Byte) match { case 5 => ... } sees no Byte - // TODO: domain of feasibly enumerable built-in types (enums, char?) + // TODO: domain of other feasibly enumerable built-in types (char?) def enumerateSubtypes(tp: Type): Option[List[Type]] = tp.typeSymbol match { + // TODO case _ if tp.isTupleType => // recurse into component types? + case UnitClass => + Some(List(UnitClass.tpe)) case BooleanClass => // patmatDebug("enum bool "+ tp) Some(List(ConstantType(Constant(true)), ConstantType(Constant(false)))) // 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 if !sym.isSealed || isPrimitiveValueClass(sym) => // patmatDebug("enum unsealed "+ (tp, sym, sym.isSealed, isPrimitiveValueClass(sym))) None |