diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-06-23 22:38:23 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-06-23 22:38:23 +0200 |
commit | c27e5f0d60c853868b3676f1449e42dd351b0644 (patch) | |
tree | cc3cbfdace3e3960fa96fd9e5187525beeea3a53 | |
parent | e0761b4dcbbc3bcbebc6392faa91bf239d247ca0 (diff) | |
download | scala-c27e5f0d60c853868b3676f1449e42dd351b0644.tar.gz scala-c27e5f0d60c853868b3676f1449e42dd351b0644.tar.bz2 scala-c27e5f0d60c853868b3676f1449e42dd351b0644.zip |
SI-5968 Eliminate spurious exhaustiveness warning with singleton types.
A singleton type is a type ripe for enumeration.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala | 2 | ||||
-rw-r--r-- | test/files/pos/t5968.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t5968.scala | 8 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala index 9b8ddffb49..f99d0e733b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala @@ -2362,6 +2362,8 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL // 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)) case sym if !sym.isSealed || isPrimitiveValueClass(sym) => // patmatDebug("enum unsealed "+ (tp, sym, sym.isSealed, isPrimitiveValueClass(sym))) None diff --git a/test/files/pos/t5968.flags b/test/files/pos/t5968.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/t5968.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t5968.scala b/test/files/pos/t5968.scala new file mode 100644 index 0000000000..0093f84fc0 --- /dev/null +++ b/test/files/pos/t5968.scala @@ -0,0 +1,8 @@ +object X { + def f(e: Either[Int, X.type]) = e match { + case Left(i) => i + case Right(X) => 0 + // SI-5986 spurious exhaustivity warning here + } +} + |