[5.3] Fix dynamic member lookup index-while-building crash #32168
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.
Index-while-building (which is enabled by default in Xcode) records the set of overridden decls for each decl it outputs in the index data. Protocols marked with the
@dynamicMemberLookup
attribute require conforming types to include asubscript(dynamicMember: KeyPath<..., ...>
) member. If a default implementation of this member was provided, the compiler would crash trying to compute its overridden decls.@dynamicMemberLookup
specified on a protocol that also provides a default implementation of the required subscript member (i.e. valid code).@main
support modified the caller of the problematic code in the crashing case to pass a valid constraint system Locator with a null anchor rather than a null Locator like it used to: f7e2abe#diff-ba9f048d1813343154c6702f3188c8b8R4554PR for master (with just the test, since it doesn't reproduce there): #32165
Resolves rdar://problem/63558609