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