aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/transform/PatternMatcher.scala15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/transform/PatternMatcher.scala b/src/dotty/tools/dotc/transform/PatternMatcher.scala
index bebe996b9..763421ea5 100644
--- a/src/dotty/tools/dotc/transform/PatternMatcher.scala
+++ b/src/dotty/tools/dotc/transform/PatternMatcher.scala
@@ -9,7 +9,7 @@ import core.Symbols._
import core.Types._
import core.Constants._
import core.StdNames._
-import dotty.tools.dotc.ast.{TreeTypeMap, tpd}
+import dotty.tools.dotc.ast.{untpd, TreeTypeMap, tpd}
import dotty.tools.dotc.core
import dotty.tools.dotc.core.DenotTransformers.DenotTransformer
import dotty.tools.dotc.core.Phases.Phase
@@ -52,6 +52,19 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
translated.ensureConforms(tree.tpe)
}
+
+ override def transformTry(tree: tpd.Try)(implicit ctx: Context, info: TransformerInfo): tpd.Tree = {
+ val selector =
+ ctx.newSymbol(ctx.owner, ctx.freshName("ex").toTermName, Flags.Synthetic, defn.ThrowableType, coord = tree.pos)
+ val sel = Ident(selector.termRef).withPos(tree.pos)
+ val rethrow = tpd.CaseDef(sel, EmptyTree, Throw(ref(selector)))
+ val newCases = tpd.CaseDef(
+ Bind(selector,untpd.Ident(nme.WILDCARD).withPos(tree.pos).withType(selector.info)),
+ EmptyTree,
+ transformMatch(tpd.Match(sel, tree.cases ::: rethrow :: Nil)))
+ cpy.Try(tree)(tree.expr, newCases :: Nil, tree.finalizer)
+ }
+
class Translator(implicit ctx: Context) {
def translator = {