Skip to content

boundary/break not allowed by safe mode #25387

@bishabosha

Description

@bishabosha

Compiler version

3.8.4-RC3

Minimized code

package example
import scala.language.experimental.safe
import scala.util.boundary

def main() = boundary(23)

Output

./safe-boundary.scala:5:14
Cannot refer to class unchecked in package scala from safe code since it is tagged @rejectSafe
def main() = boundary(23)
             ^^^^^^^^^^^^

Notes

[[syntax trees at end of                        cc]] // /Users/jamie/workspace/scripts/bar/safe-boundary.scala
package example {
  import scala.language.experimental.safe
  import scala.util.boundary
  final lazy module val safe-boundary$package: example.safe-boundary$package^{}
     = new example.safe-boundary$package()
  @SourceFile("safe-boundary.scala") @assumeSafe final module class
    safe-boundary$package() extends Object() {
    private[this] type $this = example.safe-boundary$package.type
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(
        classOf[example.safe-boundary$package.type])
    def main(): Int =
      {
        val local: (scala.util.boundary.Label[Int]^) =
          new scala.util.boundary.Label[Int]()
        (try 23 catch
          {
            case ex @ _:scala.util.boundary.Break[Int] @unchecked =>
              (if ex.isSameLabelAs(local) then ex.value else throw ex):Int
          }
        )
      }:Int
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions