Skip to content

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Sep 17, 2019

In preparation to extend this fix to support more then just closures:

  • Cover single explicit tuple argument -> N parameters via missing arguments fix

Expand tuple into N arguments to cover expect parameters.

This covers cases like this:

func foo(_: (Int, Int) -> Void) {}
foo { (bar: (Int, Int)) in } // used a single tuple type `(Int, Int)`
                             // instead of two distinct arguments
  • Fix missing argument diagnostic to support closures with captures
  • NFC: Remove "trailing" from method name for closures with missing args

…gnostic

Instead of storing contextual function type in the fix/diagnostic,
let's fetch it from context (solution and/or locator) because it's
only used when it is a trailing closure missing some arguments anyway.
…a missing arguments fix

Expand tuple into N arguments to cover expect parameters.

This covers cases like this:

```swift
func foo(_: (Int, Int) -> Void) {}
foo { (bar: (Int, Int)) in } // used a single tuple type `(Int, Int)`
                             // instead of two distinct arguments
```
…th missing args

`MissingArgumentsFailure::diagnoseClosure` can actually diagnose both
closures in argument positions as well as when their type comes from
context e.g. `let _: (Int) -> Void = {}`.
@xedin xedin requested a review from hborla September 17, 2019 19:22
@xedin
Copy link
Contributor Author

xedin commented Sep 17, 2019

@swift-ci please smoke test

@xedin xedin merged commit 5c01a11 into swiftlang:master Sep 17, 2019
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