Skip to content

[5.9][ConstraintSystem] Improvements to variadic generics inference #64820

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

Merged

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Mar 31, 2023

Cherry-pick of #64733
Cherry-pick of #64780


xedin added 4 commits March 31, 2023 10:18
…first element doesn't have one

If tuple doesn't have a label for its first element
and parameter does, let's assume parameter's label
to aid argument matching. For example:

```swift
func test(val: Int, _: String) {}

test(val: (42, "")) // expands into `(val: 42, "")`
```

Resolves: rdar://106775969
(cherry picked from commit b07dafa)
This is important if overload is variadic generic, in such cases
substitution map is used to determine actual parameter index.

(cherry picked from commit 377fd98)
For variadic generic declarations we need to compute a substituted
version of bindings because all of the packs are exploded in the
substituted function type.

```swift
func fn<each T>(_: repeat each T) {}

fn("", 42)
```

The type of `fn` in the call is `(String, Int) -> Void` but bindings
have only one parameter at index `0` with two argument positions: 0, 1.

(cherry picked from commit 1900813)
…w pack expansions

`coerceCallArguments` has to be `ParameterList::getOrigParamIndex`
to determine "original" parameter version which could be used with
un-substituted parameter list.

(cherry picked from commit 00fbdc7)
@xedin xedin added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9 labels Mar 31, 2023
@xedin xedin requested a review from hborla March 31, 2023 17:28
@xedin xedin requested a review from a team as a code owner March 31, 2023 17:28
@xedin
Copy link
Contributor Author

xedin commented Mar 31, 2023

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Mar 31, 2023

@swift-ci please test macOS platforms

@xedin
Copy link
Contributor Author

xedin commented Mar 31, 2023

@swift-ci please test macOS platform

2 similar comments
@xedin
Copy link
Contributor Author

xedin commented Mar 31, 2023

@swift-ci please test macOS platform

@xedin
Copy link
Contributor Author

xedin commented Apr 3, 2023

@swift-ci please test macOS platform

@xedin xedin merged commit f163022 into swiftlang:release/5.9 Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants