Repository navigation
Synthetic cast must not break tailrec - #26343
Conversation
sjrd
left a comment
There was a problem hiding this comment.
Code LGTM, but I have a question about the test.
There was a problem hiding this comment.
Doesn't this test need a -Werror flag with a using config to be useful?
There was a problem hiding this comment.
I thought I pushed it at the last moment when I created the PR! Maybe I am out of practice! I will make amends by amending.
There was a problem hiding this comment.
Oh, that was my other regression test where I did that! Apologies again.
There was a problem hiding this comment.
Oh wait, tailrec is a hard error already.
There was a problem hiding this comment.
Yeah I think this test is fine as-is without having to be moved to warn/, I also second-guessed myself on tailrec being an error
There was a problem hiding this comment.
| Cannot rewrite recursive call: it is not in tail position
1 error found
| case tree @ Select(qual, name) => | ||
| cpy.Select(tree)(noTailTransform(qual), name) | ||
| val qual1 = | ||
| if tree.symbol == defn.Any_asInstanceOf && tree.span.isSynthetic then |
There was a problem hiding this comment.
It would be nice to explain why so that one doesn't have to git blame to understand.
There was a problem hiding this comment.
I thought of you when I almost commented the line.
There was a problem hiding this comment.
I recommend git blame in case there are puns in the commit text.
587635c to
5be0d6e
Compare
Fixes scala#21642 Pattern matcher inserted a cast, which is no longer tail recursive. The fix ignores synthetic select of asInstanceOf for tail position. ## How much have you relied on LLM-based tools in this contribution? Not at all ## How was the solution tested? New automated tests (including the issue's reproducer, if applicable) [Cherry-picked 9a878fd]
Fixes #21642
Pattern matcher inserted a cast, which is no longer tail recursive.
The fix ignores synthetic select of asInstanceOf for tail position.
How much have you relied on LLM-based tools in this contribution?
Not at all
How was the solution tested?
New automated tests (including the issue's reproducer, if applicable)