Skip to content

[CSSimplify] Look through optionals in contextual type while resolving a closure #38104

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 Jun 25, 2021

Let's look through all optionals associated with contextual
type to make it possible to infer parameter/result type of
the closure faster e.g.:

func test(_: ((Int) -> Void)?) {
   ...
 }

test { $0 + ... }

In this case dropping optionality from contextual type
((Int) -> Void)? allows resolveClosure to infer type
of $0 directly (via getContextualParamAt) instead of
having to use type variable inference mechanism.

xedin added 2 commits June 24, 2021 15:29
…g a closure

Let's look through all optionals associated with contextual
type to make it possible to infer parameter/result type of
the closure faster e.g.:

```swift
func test(_: ((Int) -> Void)?) {
   ...
}

test { $0 + ... }
```

In this case dropping optionality from contextual type
`((Int) -> Void)?` allows `resolveClosure` to infer type
of `$0` directly (via `getContextualParamAt`) instead of
having to use type variable inference mechanism.
@xedin xedin requested a review from hborla June 25, 2021 15:34
Copy link
Member

@hborla hborla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@xedin
Copy link
Contributor Author

xedin commented Jun 25, 2021

@swift-ci please test

@xedin xedin merged commit f3b6ff0 into swiftlang:main Jun 28, 2021
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