Skip to content

SILGen: Delay function conversions to types with opened archetype arguments. #18085

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

Conversation

jckarter
Copy link
Contributor

@jckarter jckarter commented Jul 19, 2018

This comes up when invoking protocol methods on an existential that have covariant arguments of function type with Self arguments, e.g.:

protocol P {
  mutating func foo(_: (Self) -> Void)
}
func bar(x: inout P) {
  x.foo { y in return }
}

Although the type-erased method is presented as formally taking an argument of the existential type P, it still has a conversion thunk to perform type erasure on the argument coming from the underlying implementation. Since the self argument is inout, it isn't formally opened until late when formal accesses begin, so this closure conversion must also be deferred until after that occurs.

rdar://problem/42215661

…uments.

This comes up when invoking protocol methods on an existential that have covariant arguments of function type with Self arguments, e.g.:

```swift
protocol P {
  mutating func foo(_: (Self) -> Void)
}
func bar(x: inout P) {
  x.foo { y in return }
}
```

Although the type-erased method is presented as formally taking an argument of the existential type P, it still has a conversion thunk to perform type erasure on the argument coming from the underlying implementation. Since the `self` argument is inout, it isn't formally opened until late when formal accesses begin, so this closure conversion must also be deferred until after that occurs.
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@jckarter
Copy link
Contributor Author

@swift-ci Please test source compatibility

@jckarter jckarter requested a review from slavapestov July 19, 2018 20:04
@slavapestov
Copy link
Contributor

Wow, that’s simpler than I expected! Nice job.

@jckarter jckarter merged commit 08ec1ba into swiftlang:master Jul 19, 2018
@atrick
Copy link
Contributor

atrick commented Jul 20, 2018

@jckarter Thanks!

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.

3 participants