diff options
author | Clemens Winter <clemenswinter1@gmail.com> | 2016-08-03 16:10:46 +0200 |
---|---|---|
committer | Clemens Winter <clemenswinter1@gmail.com> | 2016-08-03 16:53:59 +0200 |
commit | 28bc8e83a09e00ff6c06752faee530298b22a640 (patch) | |
tree | 558060447439fd303e3ed2b6416de0e75b8093e7 | |
parent | 01bd9482d6d1565bfeb17526bed836f0feaeb0d1 (diff) | |
download | dotty-28bc8e83a09e00ff6c06752faee530298b22a640.tar.gz dotty-28bc8e83a09e00ff6c06752faee530298b22a640.tar.bz2 dotty-28bc8e83a09e00ff6c06752faee530298b22a640.zip |
Fix #1367: Add ParsedTry case to UntypedTree{Copier,Map,Accumulator}
-rw-r--r-- | src/dotty/tools/dotc/ast/untpd.scala | 9 | ||||
-rw-r--r-- | tests/repl/toplevelTry.check | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/ast/untpd.scala b/src/dotty/tools/dotc/ast/untpd.scala index b3f8747dc..3d2fe9e44 100644 --- a/src/dotty/tools/dotc/ast/untpd.scala +++ b/src/dotty/tools/dotc/ast/untpd.scala @@ -281,6 +281,11 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { case tree: ModuleDef if (name eq tree.name) && (impl eq tree.impl) => tree case _ => untpd.ModuleDef(name, impl).withPos(tree.pos) } + def ParsedTry(tree: Tree)(expr: Tree, handler: Tree, finalizer: Tree) = tree match { + case tree: ParsedTry + if (expr eq tree.expr) && (handler eq tree.handler) && (finalizer eq tree.finalizer) => tree + case _ => untpd.ParsedTry(expr, handler, finalizer).withPos(tree.pos) + } def PolyTypeDef(tree: Tree)(name: TypeName, tparams: List[TypeDef], rhs: Tree) = tree match { case tree: PolyTypeDef if (name eq tree.name) && (tparams eq tree.tparams) && (rhs eq tree.rhs) => tree case _ => new PolyTypeDef(name, tparams, rhs).withPos(tree.pos) @@ -359,6 +364,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { override def transform(tree: Tree)(implicit ctx: Context): Tree = tree match { case ModuleDef(name, impl) => cpy.ModuleDef(tree)(name, transformSub(impl)) + case ParsedTry(expr, handler, finalizer) => + cpy.ParsedTry(tree)(transform(expr), transform(handler), transform(finalizer)) case SymbolLit(str) => cpy.SymbolLit(tree)(str) case InterpolatedString(id, strings, elems) => @@ -404,6 +411,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { override def foldOver(x: X, tree: Tree)(implicit ctx: Context): X = tree match { case ModuleDef(name, impl) => this(x, impl) + case ParsedTry(expr, handler, finalizer) => + this(this(this(x, expr), handler), finalizer) case SymbolLit(str) => x case InterpolatedString(id, strings, elems) => diff --git a/tests/repl/toplevelTry.check b/tests/repl/toplevelTry.check new file mode 100644 index 000000000..9d2c87b35 --- /dev/null +++ b/tests/repl/toplevelTry.check @@ -0,0 +1,3 @@ +scala> try { 0 } catch { _: Throwable => 1 } +res0: Int = 0 +scala> :quit |