Skip to content

Fix #3627: Avoid looping when inferring types with recursive lower bounds #3714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 2, 2018

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Dec 31, 2017

Avoid looping when inferring types with recursive lower bounds in constraints

i3627.scala caused the typer to loop in several different ways. One was in isSubType,
the other in wildApprox.

The isSubType loop can be fixed by leaving monitoring on once the limit was reached
for the remainder of the top-level subtype check. I am not exactly sure what caused
the loop but the observation was a very long or infinite oscillation around the monitoring
limit. Leaving monitoring on is certainly not incorrect - the previous trick to turn
it off for recursions under the limit was purely for optimization. On the other hand
I am not sure whether the new scheme is sufficient, or whether we can still have
the situation of infinite recursions that stay under the depth limit.

The wildApprox loop was a simple bug (the seen value was not propagated correctly
to the TypeMap). The fix also removed a case in wildApproxBounds that had no clear purpose.

…straints

i3627.scala caused the typer to loop in several different ways. One was in isSubType,
the other in wildApprox.

The isSubType loop can be fixed by leaving monitoring on once the limit was reached
for the remainder of the top-level subtype check. I am not exactly sure what caused
the loop but the observation was a very long or infinite oscillation around the monitoring
limit. Leaving monitoring on is certainly not incorrect - the previous trick to turn
it off for recursions under the limit was purely for optimization. On the other hand
I am not sure whether the new scheme is sufficient, or whether we can still have
the situation of infinite recursions that stay under the depth limit.

The wildApprox loop was a simple bug (the `seen` value was not propagated correctly
to the TypeMap). The fix also removed a case in wildApproxBounds that had no clear purpose.
This is purely an optimization. It would have fixed by itself
the subtype loop in the first part of i3627.scala but not the
one in the second part.
@odersky odersky requested a review from smarter January 13, 2018 19:41
@smarter smarter self-assigned this Jan 18, 2018
@odersky odersky merged commit 3ca1171 into scala:master Feb 2, 2018
@allanrenucci allanrenucci deleted the fix-#3627 branch February 14, 2018 16:34
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