Skip to content

[4.2] SILGen: Delay function conversions to types with opened archetype arguments. #18086

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

Explanation: Fixes a crash when invoking a protocol method with function arguments that take Self on an existential type.

Scope: Regression introduced in 4.2 beta 3 by fix for 39524104

Issue: rdar://problem/42215661

Risk: Low, targeted fix for a specific case

Testing: Swift CI, compatibility suite

Reviewed by: @slavapestov

@jckarter
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 87d58e00d3076882d3f2290f624fa4bef21515d8

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 87d58e00d3076882d3f2290f624fa4bef21515d8

…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 jckarter force-pushed the inout-existential-opened-type-function-conversion-4.2 branch from 87d58e0 to d4d66ca Compare July 19, 2018 21:53
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 87d58e00d3076882d3f2290f624fa4bef21515d8

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 87d58e00d3076882d3f2290f624fa4bef21515d8

@jckarter
Copy link
Contributor Author

@swift-ci Please nominate

@jckarter jckarter merged commit e6d508b into swiftlang:swift-4.2-branch Jul 20, 2018
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