Skip to content

Fix #1367: Add ParsedTry case to UntypedTree{Copier,Map,Accumulator} #1439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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