Skip to content

Commit

Permalink
Merge pull request scala#1439 from cswinter/parsedtry
Browse files Browse the repository at this point in the history
Fix scala#1367: Add ParsedTry case to UntypedTree{Copier,Map,Accumulator}
  • Loading branch information
smarter authored Aug 8, 2016
2 parents 01bd948 + 28bc8e8 commit be1f099
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) =>
Expand Down Expand Up @@ -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) =>
Expand Down
3 changes: 3 additions & 0 deletions tests/repl/toplevelTry.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scala> try { 0 } catch { _: Throwable => 1 }
res0: Int = 0
scala> :quit

0 comments on commit be1f099

Please sign in to comment.