Complete owners of type parameters before parameters themselves #10972
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.
Fixes #10967
Fixes #10638
I minimized #10967 further to:
What happened was:
companion
CollCompanion[CC1]
CC2
of CollCompanion in order to make sure the argument is CC1 is kind correct.A
ofCC2
CollCompanion
.CC2
, hence the cycle.Note that if the definitions of
CollBase
andCollCompanion
appear in reverse order,no cycle results, since then
CollCompanion
and its type parameters were completed beforecompleting
companion
.To break the cycle, we can complete the owner of a type parameter before starting
completion of the parameter. Furthermore, we need to do this only in Namer, which is
where the complex checking patterns are. I have not tried to also treat symbols that
are not type definitions that way. It's not necessary to fix #10967 but it might help
for other cycles (or it might cause them, these things are tricky!). I did try to
make the behavior universal for all completers, not just Namers, but that caused
crashes immediately.