Move generic stack operations into handle_impl.cpp (Refactor Impl construction 8/7) #6484
+529
−524
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.
Instead of burying operations to pop the generic stack in
GetOrAddImpl, we move them up to handle_impl.cpp inBuildImplDecl, which puts them at the same level as other operations on the generic stack, likeStartGenericDeclorFinishGenericDefinition.To do so, we split
GetOrAddImplinto a few pieces:FindImplIdfinds an existing Impl that matches the declaration, or returns a LookupBucketRef and whether an error was diagnosed instead.AddImpltakes a fully builtImpl, makes anImplIdfor it, and does additional steps for a newImplverifying it and applyingextend.AddImplWitnessForDeclarationconstructs theImpl's witness, which must be done between two generic steps in order to use the generic's self specific but also add the witness instruction to the generic.We group the logic to build the initial table in the definition and to complete it in the definition together in
impl.cpp. And we save a lookup into the ImplStore by passing Impl by reference toFinishImplWitness, as we now do for other similar functions inimpl.h.This is based on #6470.