@@ -50,7 +50,8 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
50
50
51
51
override def transformMatch (tree : Match )(implicit ctx : Context , info : TransformerInfo ): Tree = {
52
52
val translated = new Translator ()(ctx).translator.translateMatch(tree)
53
- translated.ensureConforms(tree.tpe)
53
+
54
+ Typed (translated.ensureConforms(tree.tpe), TypeTree (tree.tpe))
54
55
}
55
56
56
57
class Translator (implicit ctx : Context ) {
@@ -1136,7 +1137,13 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
1136
1137
* this could probably optimized... (but note that the matchStrategy must be solved for each nested patternmatch)
1137
1138
*/
1138
1139
def translateMatch (match_ : Match ): Tree = {
1139
- val Match (selector, cases) = match_
1140
+ val Match (sel, cases) = match_
1141
+
1142
+ val selectorTp = elimAnonymousClass(sel.tpe.widen/* withoutAnnotations*/ )
1143
+
1144
+ val selectorSym =
1145
+ if (sel ne ExceptionHandlerSel ) freshSym(sel.pos, selectorTp, " selector" )
1146
+ else freshSym(match_.pos, defn.ThrowableType , " ex" )
1140
1147
1141
1148
val (nonSyntheticCases, defaultOverride) = cases match {
1142
1149
case init :+ last if isSyntheticDefaultCase(last) => (init, Some (((scrut : Symbol ) => last.body)))
@@ -1155,23 +1162,20 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
1155
1162
1156
1163
// val start = if (Statistics.canEnable) Statistics.startTimer(patmatNanos) else null
1157
1164
1158
- val selectorTp = elimAnonymousClass(selector.tpe.widen/* withoutAnnotations*/ )
1159
-
1160
1165
// when one of the internal cps-type-state annotations is present, strip all CPS annotations
1161
1166
// /val origPt = removeCPSFromPt(match_.tpe)
1162
1167
// relevant test cases: pos/existentials-harmful.scala, pos/gadt-gilles.scala, pos/t2683.scala, pos/virtpatmat_exist4.scala
1163
1168
// pt is the skolemized version
1164
1169
val pt = match_.tpe.widen // repeatedToSeq(origPt)
1165
1170
1166
1171
// val packedPt = repeatedToSeq(typer.packedType(match_, context.owner))
1167
- val selectorSym = freshSym(selector.pos, selectorTp, " selector" )
1168
1172
selectorSym.setFlag(Flags .SyntheticCase )
1169
1173
1170
1174
// pt = Any* occurs when compiling test/files/pos/annotDepMethType.scala with -Xexperimental
1171
- val combined = combineCases(selector , selectorSym, nonSyntheticCases map translateCase(selectorSym, pt), pt, ctx.owner, defaultOverride)
1175
+ val combined = combineCases(sel , selectorSym, nonSyntheticCases map translateCase(selectorSym, pt), pt, ctx.owner, defaultOverride)
1172
1176
1173
1177
// if (Statistics.canEnable) Statistics.stopTimer(patmatNanos, start)
1174
- Block (List (ValDef (selectorSym,selector )), combined)
1178
+ Block (List (ValDef (selectorSym, sel )), combined)
1175
1179
}
1176
1180
1177
1181
// return list of typed CaseDefs that are supported by the backend (typed/bind/wildcard)
0 commit comments