Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CS] Call checkParameterList for single-expr closures #76473

Merged
merged 2 commits into from
Sep 16, 2024

Conversation

hamishknight
Copy link
Contributor

Previously we would only call this in the delayed application logic, which is currently run for multi-statement closures. I'm planning on removing that code path, which uncovered this issue.

Resolves #76291

Previously we would only call this in the delayed
application logic, which is currently run for
multi-statement closures. I'm planning on
removing that code path, which uncovered this
issue.
We need to make sure property wrappers are
applied before `checkParameterList`.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility

@hamishknight hamishknight merged commit c9c962b into swiftlang:main Sep 16, 2024
7 checks passed
@hamishknight hamishknight deleted the attrick branch September 16, 2024 16:16
slavapestov added a commit to slavapestov/swift that referenced this pull request Nov 8, 2024
…larations

A function declaration cannot have an opaque parameter type appearing in
consuming position:

    func f(_: (some P) -> ()) {}

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 problem has been there ever since the check was added, but only
for multi-statement closures.

When swiftlang#76473 made it so we always
call TypeChecker::checkParameterList(), which exposed the problem in a
single-expression closure in an existing project.

Fixes rdar://139237671.
slavapestov added a commit to slavapestov/swift that referenced this pull request Nov 8, 2024
…larations

A function declaration cannot have an opaque parameter type appearing in
consuming position:

    func f(_: (some P) -> ()) {}

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 swiftlang#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Single-expression closures don't do TypeChecker::checkParameterList
2 participants