[IDE] Fix SyntaxModel crash due to out-of-order walking of EnumElementDecls #26270
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.
ModelASTWalker
was previously constructingSyntaxNode
s forEnumElementDecl
s manually when visiting their associatedEnumCaseDecl
so that they would appear as its children rather than its siblings. It wasn't actually walking these nodes though, so missed handling some things, e.g. closures passed as default argument values. It was also still walking the sameEnumElementDecl
s again in the sibling position. Because theTokenNode
s in the range of eachEnumElementDecl
were consumed when they were manually constructed, this second visit was triggering some recently added assertions in the handling of custom attributes, which expected the correspondingTokenNode
s to still be present.Resolves rdar://problem/53313197