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

[ConstraintSystem] Allow injecting callAsFunction after defaulted arguments #59432

Merged
merged 2 commits into from
Jun 27, 2022

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jun 14, 2022

  • Adjust argument matching to be less aggressive while matching misplaced trailing closures
    against defaulted parameters that do not accept trailing closures.

    For example:

    func test(a: Int? = 42, b: String? = nil) {}
    
    test {
      ...
    }

    Trailing closure in this case should be marked as "extraneous" instead of matched
    against parameter a:.

  • If trailing closure is extraneous in a call to .init on callable type, let's not attempt to
    to fix it and allow solver to inject .callAsFunction first.

Resolves: rdar://problem/94959816

@xedin xedin requested a review from hborla June 14, 2022 17:15
@xedin
Copy link
Contributor Author

xedin commented Jun 14, 2022

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Jun 14, 2022

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Jun 14, 2022

@swift-ci please build toolchain macos

If current parameter cannot accept a trailing closure, let's match
current closure argument to it only if there is absolutely no
possible other choice e.g. no other parameters (defaulted or not)
that could accept the closure via a less restrictive backward scan.
Detect that extraneous closure belongs to `.init` call on a callable
type and let the solver inject `.callAsFunction` before fixing it.

This prevents incorrect "extraneous trailing closure" diagnostic when
issue is located inside of the closure itself.
@xedin
Copy link
Contributor Author

xedin commented Jun 14, 2022

@swift-ci please build toolchain macos

@xedin
Copy link
Contributor Author

xedin commented Jun 14, 2022

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Jun 14, 2022

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Jun 27, 2022

@swift-ci please smoke test macOS platform

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.

2 participants