Skip to content

Conversation

@allanrenucci
Copy link
Contributor

No description provided.

@sjrd
Copy link
Member

sjrd commented Nov 7, 2018

The optimization is incorrect. It is possible to re-enter a tail-pos context even from some places where we are in a non-tail-pos context. The most important example is when finding a return[label] expr where the label: { ... } block was in tail position, but the return was not. In that case, expr must be considered to be in tail position. This is critical for tail-recursive calls in the cases of a pattern match.

@allanrenucci allanrenucci force-pushed the fix-5163-bis branch 5 times, most recently from 3eca547 to f8f2b4e Compare November 8, 2018 13:36
@allanrenucci allanrenucci changed the title Fix #5163: Report tailrec failures on recursive call targeting supertype Tailrec improvements Nov 8, 2018
We can stop traversing a tree in Tailrec as soon as we are not in tail
position anymore and we are not within a labeled block in tail position.
We keep traversing the tree however if the method is @tailrec annotated
to report errors on eventual recursive calls.
@allanrenucci allanrenucci merged commit a9029dc into scala:master Nov 9, 2018
@allanrenucci allanrenucci deleted the fix-5163-bis branch November 9, 2018 17:10
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.

2 participants