File tree Expand file tree Collapse file tree 3 files changed +8
-12
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 3 files changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ object DropBreaks:
2424 class LabelUsage (val goto : TermSymbol , val enclMeth : Symbol ):
2525 /** The number of references to associated label that come from labeled returns */
2626 var returnRefs : Int = 0
27- /** The number of other references to assocated label */
27+ /** The number of other references to associated label */
2828 var otherRefs : Int = 0
2929
3030 private val LabelUsages = new Property .Key [Map [Symbol , LabelUsage ]]
@@ -167,7 +167,7 @@ class DropBreaks extends MiniPhase, RecordStackChange:
167167 override def prepareForApply (tree : Apply )(using Context ): Context = tree match
168168 case Break (_, _) => ctx
169169 case _ => stackChange
170-
170+
171171 // other stack changing operations are handled in RecordStackChange
172172
173173 /** If `tree` is a BreakBoundary, transform it as follows:
@@ -221,8 +221,4 @@ class DropBreaks extends MiniPhase, RecordStackChange:
221221 uses.otherRefs += 1
222222 tree
223223
224- // override def transformReturn(tree: Return)(using Context): Tree =
225- // if !tree.from.isEmpty && tree.expr.tpe.isExactlyNothing then tree.expr
226- // else tree
227-
228224end DropBreaks
Original file line number Diff line number Diff line change @@ -8,13 +8,13 @@ object break:
88 /** Abort current computation and instead return `value` as the value of
99 * the enclosing `boundary` call that created `label`.
1010 */
11- def apply [T ](value : T )(using l : boundary.Label [T ]): Nothing =
12- l .break(value)
11+ def apply [T ](value : T )(using label : boundary.Label [T ]): Nothing =
12+ label .break(value)
1313
1414 /** Abort current computation and instead continue after the `boundary` call that
1515 * created `label`.
1616 */
17- def apply ()(using l : boundary.Label [Unit ]): Nothing =
18- apply (())
17+ def apply ()(using label : boundary.Label [Unit ]): Nothing =
18+ label.break (())
1919
20- end break
20+ end break
Original file line number Diff line number Diff line change 11package optionMockup:
2- import dotty .util .boundary
2+ import scala .util .boundary
33 object optional :
44 transparent inline def apply [T ](inline body : boundary.Label [None .type ] ?=> T ): Option [T ] =
55 boundary(Some (body))
You can’t perform that action at this time.
0 commit comments