Skip to content

[CSApply] Teach coerceCallArguments about variadic generics #64780

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
merged 3 commits into from
Mar 31, 2023

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Mar 30, 2023

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.

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.

This is important if overload is variadic generic, in such cases
substitution map is used to determine actual parameter index.
@xedin xedin requested a review from hborla as a code owner March 30, 2023 19:05
@xedin
Copy link
Contributor Author

xedin commented Mar 30, 2023

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Mar 30, 2023

@swift-ci please test Windows platform

xedin added 2 commits March 30, 2023 15:02
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.
…w pack expansions

`coerceCallArguments` has to be `ParameterList::getOrigParamIndex`
to determine "original" parameter version which could be used with
un-substituted parameter list.
@xedin xedin force-pushed the fix-default-args-with-variadic-generics branch from 484a9df to 00fbdc7 Compare March 30, 2023 23:48
@xedin
Copy link
Contributor Author

xedin commented Mar 30, 2023

@swift-ci please test

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