aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform/PatternMatcher.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/transform/PatternMatcher.scala')
-rw-r--r--src/dotty/tools/dotc/transform/PatternMatcher.scala18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/transform/PatternMatcher.scala b/src/dotty/tools/dotc/transform/PatternMatcher.scala
index 839189948..21b56959b 100644
--- a/src/dotty/tools/dotc/transform/PatternMatcher.scala
+++ b/src/dotty/tools/dotc/transform/PatternMatcher.scala
@@ -24,6 +24,7 @@ import Applications._
import TypeApplications._
import SymUtils._, core.NameOps._
import core.Mode
+import patmat._
import dotty.tools.dotc.util.Positions.Position
import dotty.tools.dotc.core.Decorators._
@@ -52,6 +53,13 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
override def transformMatch(tree: Match)(implicit ctx: Context, info: TransformerInfo): Tree = {
val translated = new Translator()(ctx).translator.translateMatch(tree)
+ // check exhaustivity and unreachability
+ val engine = new SpaceEngine
+ if (engine.checkable(tree)) {
+ engine.checkExhaustivity(tree)
+ engine.checkRedundancy(tree)
+ }
+
translated.ensureConforms(tree.tpe)
}
@@ -1244,13 +1252,6 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
case _ => false
}
- def elimAnonymousClass(t: Type) = t match {
- case t:TypeRef if t.symbol.isAnonymousClass =>
- t.symbol.asClass.typeRef.asSeenFrom(t.prefix, t.symbol.owner)
- case _ =>
- t
- }
-
/** Implement a pattern match by turning its cases (including the implicit failure case)
* into the corresponding (monadic) extractors, and combining them with the `orElse` combinator.
*
@@ -1264,7 +1265,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
def translateMatch(match_ : Match): Tree = {
val Match(sel, cases) = match_
- val selectorTp = elimAnonymousClass(sel.tpe.widen/*withoutAnnotations*/)
+ val selectorTp = sel.tpe.widen.deAnonymize/*withoutAnnotations*/
val selectorSym = freshSym(sel.pos, selectorTp, "selector")
@@ -1273,6 +1274,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
case _ => (cases, None)
}
+
// checkMatchVariablePatterns(nonSyntheticCases) // only used for warnings
// we don't transform after uncurry