Skip to content

Commit 39e63f3

Browse files
committed
Adress some review comments and other tweaks
1 parent 3e5a678 commit 39e63f3

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff 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-
228224
end DropBreaks

library/src/scala/util/break.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff 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

tests/run/errorhandling/kostas.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package 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))

0 commit comments

Comments
 (0)