[Property Wrappers] Fix a crash in merge-modules with wrapped parameters. #37407
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.
This is fallout from #36521 that caused a crash in merge modules when the source was compiled with
-emit-module-source-info
and-enable-testing
.After deserializing a property wrapper on a parameter, we check if the interface type of the parameter is valid. For property wrappers with
init(projectedValue)
, this ends up going throughPropertyWrapperBackingPropertyTypeRequest
, which is called fromParamDecl::toFunctionParam
. After the above PR, this request now depends onPropertyWrapperAuxiliaryVariablesRequest
. The compiler ended up in infinite recursion (and eventually crashed) trying to synthesize the auxiliary variables for the wrapped parameter, because it got stuck trying to find the serialized location of the wrapped parameter. The fix is to return early from computing the backing property wrapper type in the case where the declaration came from a module file, because the auxiliary variables have already been computed and type checked anyway.Note: I think a better way to handle this is to set the resolved type of the wrapper attribute in the constraint system (and get rid of the side cache for the backing type) so it’s always serialized with the resolved type, but doing this breaks a lot of interface printing and SourceKit tests, and I intend to cherry-pick this to
release/5.5
so I'd like to keep the fix targeted for now.Resolves: rdar://77804605