@@ -532,8 +532,15 @@ object Trees {
532532 type ThisTree [- T >: Untyped ] = CaseDef [T ]
533533 }
534534
535+ /** label[tpt]: { expr } */
536+ case class Labeled [- T >: Untyped ] private [ast] (bind : Bind [T ], expr : Tree [T ])
537+ extends NameTree [T ] {
538+ type ThisTree [- T >: Untyped ] = Labeled [T ]
539+ def name : Name = bind.name
540+ }
541+
535542 /** return expr
536- * where `from` refers to the method from which the return takes place
543+ * where `from` refers to the method or label from which the return takes place
537544 * After program transformations this is not necessarily the enclosing method, because
538545 * closures can intervene.
539546 */
@@ -896,6 +903,7 @@ object Trees {
896903 type Match = Trees .Match [T ]
897904 type RewriteMatch = Trees .RewriteMatch [T ]
898905 type CaseDef = Trees .CaseDef [T ]
906+ type Labeled = Trees .Labeled [T ]
899907 type Return = Trees .Return [T ]
900908 type Try = Trees .Try [T ]
901909 type SeqLiteral = Trees .SeqLiteral [T ]
@@ -1044,6 +1052,10 @@ object Trees {
10441052 case tree : CaseDef if (pat eq tree.pat) && (guard eq tree.guard) && (body eq tree.body) => tree
10451053 case _ => finalize(tree, untpd.CaseDef (pat, guard, body))
10461054 }
1055+ def Labeled (tree : Tree )(bind : Bind , expr : Tree )(implicit ctx : Context ): Labeled = tree match {
1056+ case tree : Labeled if (bind eq tree.bind) && (expr eq tree.expr) => tree
1057+ case _ => finalize(tree, untpd.Labeled (bind, expr))
1058+ }
10471059 def Return (tree : Tree )(expr : Tree , from : Tree )(implicit ctx : Context ): Return = tree match {
10481060 case tree : Return if (expr eq tree.expr) && (from eq tree.from) => tree
10491061 case _ => finalize(tree, untpd.Return (expr, from))
@@ -1218,6 +1230,8 @@ object Trees {
12181230 cpy.Match (tree)(transform(selector), transformSub(cases))
12191231 case CaseDef (pat, guard, body) =>
12201232 cpy.CaseDef (tree)(transform(pat), transform(guard), transform(body))
1233+ case Labeled (bind, expr) =>
1234+ cpy.Labeled (tree)(transformSub(bind), transform(expr))
12211235 case Return (expr, from) =>
12221236 cpy.Return (tree)(transform(expr), transformSub(from))
12231237 case Try (block, cases, finalizer) =>
@@ -1350,6 +1364,8 @@ object Trees {
13501364 this (this (x, selector), cases)
13511365 case CaseDef (pat, guard, body) =>
13521366 this (this (this (x, pat), guard), body)
1367+ case Labeled (bind, expr) =>
1368+ this (this (x, bind), expr)
13531369 case Return (expr, from) =>
13541370 this (this (x, expr), from)
13551371 case Try (block, handler, finalizer) =>
0 commit comments