Skip to content

Commit 1b6f182

Browse files
committed
Add label extractor
1 parent 562c72e commit 1b6f182

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

compiler/src/dotty/tools/dotc/transform/DropBreaks.scala

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,22 @@ class DropBreaks extends MiniPhase:
105105
* throw new Break[...](local, arg): Nothing
106106
*/
107107
def unapply(tree: Tree)(using Context): Option[(Symbol, Tree)] = tree match
108-
case Apply(throww, Apply(constr, Inlined(_, _, id: Ident) :: arg :: Nil) :: Nil)
108+
case Apply(throww, Apply(constr, Label(id) :: arg :: Nil) :: Nil)
109109
if throww.symbol == defn.throwMethod
110-
&& id.symbol.name == nme.local
111110
&& constr.symbol.isClassConstructor && constr.symbol.owner == defn.BreakClass =>
112-
Some((id.symbol, arg))
111+
Some((id, arg))
113112
case _ =>
114113
None
114+
private object Label:
115+
def unapply(tree: Tree)(using Context): Option[Symbol] = tree match
116+
case id: Ident if id.symbol.name == nme.local =>
117+
Some(id.symbol)
118+
case Inlined(_, Nil, expansion) =>
119+
unapply(expansion)
120+
case Block(Nil, expansion) =>
121+
unapply(expansion)
122+
case _ =>
123+
None
115124
end BreakThrow
116125

117126
/** The LabelUsage data associated with `lbl` in the current context */

0 commit comments

Comments
 (0)