@@ -969,16 +969,21 @@ object PatternMatcher {
969
969
case Block (_, Match (_, cases)) => cases
970
970
case _ => Nil
971
971
}
972
- def numTypes (cdefs : List [CaseDef ]): Int = {
973
- def patTypes (pat : Tree ): List [Type ] = pat match {
974
- case Alternative (pats) => pats.flatMap(patTypes)
975
- case _ => pat.tpe :: Nil
976
- }
977
- val tpes = cdefs.flatMap(patTypes)
978
- tpes.toSet.size: Int // without the type ascription, testPickling fails because of #2840.
972
+ def typesInPattern (pat : Tree ): List [Type ] = pat match {
973
+ case Alternative (pats) => pats.flatMap(typesInPattern)
974
+ case _ => pat.tpe :: Nil
979
975
}
980
- if (numTypes(resultCases) < numTypes(original.cases))
976
+ def typesInCases (cdefs : List [CaseDef ]): List [Type ] =
977
+ cdefs.flatMap(cdef => typesInPattern(cdef.pat))
978
+ def numTypes (cdefs : List [CaseDef ]): Int =
979
+ typesInCases(cdefs).toSet.size: Int // without the type ascription, testPickling fails because of #2840.
980
+ if (numTypes(resultCases) < numTypes(original.cases)) {
981
+ patmatch.println(i " switch warning for ${ctx.compilationUnit}" )
982
+ patmatch.println(i " original types: ${typesInCases(original.cases)}%, % " )
983
+ patmatch.println(i " switch types : ${typesInCases(resultCases)}%, % " )
984
+ patmatch.println(i " tree = $result" )
981
985
ctx.warning(UnableToEmitSwitch (), original.pos)
986
+ }
982
987
case _ =>
983
988
}
984
989
0 commit comments