Fix #3627: Avoid looping when inferring types with recursive lower bounds #3714
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 correctlyto the TypeMap). The fix also removed a case in wildApproxBounds that had no clear purpose.