Skip to content

V2: drop use of unchecked in boundary.apply#26149

Open
bishabosha wants to merge 2 commits into
scala:mainfrom
dotty-staging:stdlib-boundary-internal-cast-throw
Open

V2: drop use of unchecked in boundary.apply#26149
bishabosha wants to merge 2 commits into
scala:mainfrom
dotty-staging:stdlib-boundary-internal-cast-throw

Conversation

@bishabosha
Copy link
Copy Markdown
Member

@bishabosha bishabosha commented May 22, 2026

introduce new method ex.getAsLabelOrThrow[T](local) on Break class that hides away the cast-or-rethrow logic so safe-mode checking will not see it when it inspects inlined code.

Therefore requires minor release.

Add case in dropBreaks miniphase to detect and elide the new shape for boundary.apply - tested in compiler/test/dotty/tools/backend/jvm/LabelBytecodeTests.scala

fixes #25387

How much have you relied on LLM-based tools in this contribution?

Not at all

How was the solution tested?

New automated tests

@bishabosha bishabosha requested a review from a team as a code owner May 22, 2026 14:48
@bishabosha bishabosha added the needs-minor-release This PR cannot be merged until the next minor release label May 22, 2026
test in compiler/test/dotty/tools/backend/jvm/LabelBytecodeTests.scala
that the dropBreaks optimisation still holds.

introduce new method `ex.getAsLabelOrThrow[T](local)` on Break class
that hides away the cast-or-rethrow logic so safe-mode checking will
not see it when it inspects inlined code.

Therefore requires minor release.

fixes scala#25387
@bishabosha bishabosha force-pushed the stdlib-boundary-internal-cast-throw branch from 37bafcc to 498406b Compare May 22, 2026 15:01
@bishabosha
Copy link
Copy Markdown
Member Author

@odersky as you highlighted in the main issue, this would be unnecessary if unsafe checking stops at the boundary of a @assumeSafe inlined method call

@odersky
Copy link
Copy Markdown
Contributor

odersky commented May 23, 2026

Yes, I think we should change the compiler's behavior instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-minor-release This PR cannot be merged until the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

boundary/break not allowed by safe mode

2 participants