Skip to content

Handle Typed(_: SubMatch) in PatternMatcher#25904

Draft
EugeneFlesselle wants to merge 3 commits intoscala:mainfrom
dotty-staging:i25746
Draft

Handle Typed(_: SubMatch) in PatternMatcher#25904
EugeneFlesselle wants to merge 3 commits intoscala:mainfrom
dotty-staging:i25746

Conversation

@EugeneFlesselle
Copy link
Copy Markdown
Contributor

Based on #25778 by @zielinsky
Fixes #25746

Strip Typed(_, _) proxies around SubMatches when computing pattern plan in PatternMatcher.

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

Not at all

How was the solution tested?

Covered by existing tests from #25778

Copy link
Copy Markdown
Member

@zielinsky zielinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my first attempt and I think this change can be simplified - I don't see why we need to convert the value to a method?

Edit: Okkk now I see, sorry (It's already 6 p.m., a little late) :)
Edit2: My first attempt was only to add one case:

case Typed(t: SubMatch, _) => subMatchPlan(t)

so I didn't need to change the value to a method - but your solution looks a way better.

@EugeneFlesselle
Copy link
Copy Markdown
Contributor Author

That was my first attempt and I think this change can be simplified

Did this approach cause issues, which led to the alternative fix?

I don't see why we need to convert the value to a method?

So the logic is applied recursively

@zielinsky
Copy link
Copy Markdown
Member

zielinsky commented Apr 22, 2026

Did this approach cause issues, which led to the alternative fix?

This fix felt like a band-aid at first. I was also not sure if just stripping the Typed there was safe, since it was put there for a reason. That's why I pushed Typed below into each case body instead.

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.

RuntimeException: Invalid pattern in Match node using subCases

2 participants