@@ -98,6 +98,7 @@ object PatternMatcher {
98
98
sym.is(Synthetic ) &&
99
99
(sym.is(Label ) || sym.name.is(PatMatStdBinderName ))
100
100
101
+ /** Test whether a type refers to a pattern-generated variable */
101
102
private val refersToInternal = new TypeAccumulator [Boolean ] {
102
103
def apply (x : Boolean , tp : Type ) =
103
104
x || {
@@ -108,20 +109,9 @@ object PatternMatcher {
108
109
} || foldOver(x, tp)
109
110
}
110
111
111
- /** A type map that eliminates all patternmatcher-generated termrefs that
112
- * can be replaced by a source-level alias .
112
+ /** Widen type as far as necessary so that it does not refer to a pattern-
113
+ * generated variable .
113
114
*/
114
- private val sanitize2 = new TypeMap {
115
- def apply (t : Type ): Type = t.widenExpr match {
116
- case t : TermRef if isPatmatGenerated(t.symbol) =>
117
- t.info.widenExpr match {
118
- case t1 : TermRef => apply(t1)
119
- case _ => t
120
- }
121
- case t => mapOver(t)
122
- }
123
- }
124
-
125
115
private def sanitize (tp : Type ): Type = tp.widenExpr match {
126
116
case tp : TermRef if refersToInternal(false , tp) => sanitize(tp.underlying)
127
117
case tp => tp
@@ -908,8 +898,12 @@ object PatternMatcher {
908
898
case Block (_, Match (_, cases)) => cases
909
899
case _ => Nil
910
900
}
911
- if (resultCases.length < original.cases.length)
912
- ctx.warning(s " could not emit switch for @switch annotated match " , original.pos)
901
+ def numConsts (cdefs : List [CaseDef ]) = {
902
+ val tpes = cdefs.map(_.pat.tpe)
903
+ tpes.toSet.size
904
+ }
905
+ if (numConsts(resultCases) < numConsts(original.cases))
906
+ ctx.warning(i " could not emit switch for @switch annotated match " , original.pos)
913
907
case _ =>
914
908
}
915
909
0 commit comments