Skip to content

fix: #25843 Strip capture annotations when analyzing match type cases#26306

Open
halotukozak wants to merge 1 commit into
scala:mainfrom
halotukozak:fix/i25843
Open

fix: #25843 Strip capture annotations when analyzing match type cases#26306
halotukozak wants to merge 1 commit into
scala:mainfrom
halotukozak:fix/i25843

Conversation

@halotukozak

Copy link
Copy Markdown
Contributor

Fixes #25843

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

Extensively, for finding the root cause. Self-reviewed before the PR.

How was the solution tested?

New automated test i25843.scala added

…a#25843)

During capture checking, a match type case can be wrapped in capture
annotations, e.g. `AnnotatedType(MatchCase(...), CaptureAnnotation)`.
`MatchTypeCaseSpec.analyze` did not account for this: the annotated case
matched neither the `HKTypeLambda` cases nor `defn.MatchCase`, so the
`@unchecked` destructuring threw a MatchError and crashed the compiler
during the CheckCaptures phase.

Strip the annotations before destructuring: recurse through AnnotatedType
to the underlying case, and dealias annotations off the result type in the
HKTypeLambda case. For non-annotated match types this is a no-op.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

capture-checking + match-type reduction crash

1 participant