Clearer error message when SAM conversion is rejected for a sealed or final type - #26639
Open
SolalPirelli wants to merge 2 commits into
Open
Clearer error message when SAM conversion is rejected for a sealed or final type#26639SolalPirelli wants to merge 2 commits into
SolalPirelli wants to merge 2 commits into
Conversation
SolalPirelli
marked this pull request as ready for review
July 29, 2026 09:30
odersky
requested changes
Aug 12, 2026
| unapply(tp, false) | ||
|
|
||
| /** Optionally ignores `final` and `sealed`, so that error messages can point to this specific problem. */ | ||
| def unapply(tp: Type, ignoreFinalOrSealed: Boolean)(using Context): Option[(MethodType, Type)] = |
Contributor
There was a problem hiding this comment.
Since this is not a real unapply method, we might want to choose anothetr name. "deconstruct" maybe?
| end samParent | ||
|
|
||
| def samClass(tp: Type)(using Context): Symbol = tp match | ||
| private def samClass(tp: Type, ignoreFinalOrSealed: Boolean)(using Context): Symbol = tp match |
Contributor
There was a problem hiding this comment.
We can avoid the tiresome repetition of the second parameter by moving samClass into unapply (or deconstruct).
Contributor
Author
There was a problem hiding this comment.
That's cleaner indeed, thanks
SolalPirelli
force-pushed
the
solal/closure-to-sealed-trait
branch
from
August 12, 2026 12:32
d857b41 to
2448552
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #26617
Not sure this is that useful? But it's not too complex to add.
Have you relied on LLM-based tools in this contribution?
No
How was the solution tested?
New automated tests (including the issue's reproducer, if applicable)