Sema: Allow closure parameter lists to reference opaque parameter declarations #77491
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.
A function declaration cannot have an opaque parameter type appearing in consuming position:
However, we should skip this check for a closure, because if the closure's parameter list references an opaque parameter declaration, it means something else: namely, the inferred type of the closure refers to an opaque parameter from an outer scope. That's allowed.
This unnecessary prohibition has been there ever since the check was added, but only for multi-statement closures, so nobody seemed to notice.
When #76473 made it so we always call TypeChecker::checkParameterList(), this exposed the problem in a single-expression closure in an existing project.
Fixes rdar://139237671.