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
[SR-6478] [SE-0143] IRGen Crash with conditional conformance of generic struct #49028
Comments
@slavapestov or @rjmccall, I may ask for your help in understanding how IRGen is supposed to work for these. |
Significantly reduced so we no longer need the standard library: protocol P {
associatedtype A: P
}
protocol Q: P where A: Q {
}
struct Wrapper<T: P>: P {
typealias A = Wrapper<T>
}
extension Wrapper: Q where T: Q { } |
The attached hack-patch works around a substitution issue where we don't have the contextual types we need. It get us to an assertion where, in the process of emitting the witness table `Wrapper<T>: Q`, we emit the witness table access function for `Self.A: Q`, which in this case is also `Wrapper<T>: Q`. We fail in `emitConditionalConformancesBuffer()`, because we're trying to fill in the (abstract) conformance of `T: Q`... which isn't a known fulfillment. |
The extra thing that's done for conditional conformances in EmitPolymorphicParameters::bindExtraSources also needs to be done in the conformance's access functions. |
We should also do the obvious optimization of adding the self conformance as unscoped local type data; if you do that, you'll need to change the test case to make A a slightly different type that still requires T: Q. Make sure you do this in the type-metadata access function, too, for which the test case would be an associated type with an unconditional conformance requirement. |
Merged that PR to get us further, but I'm deeply troubled by the first commit in there. I'm going to hold this bug open until I find a more palatable solution. |
Attachment: Download
Additional Detail from JIRA
md5: f3eea6684af9f3a682ffbda319003a4d
Issue Description:
The following crashes in IR generation when emitting the witness table for the conditional conformance `MySlice: BidirectionalCollection`:
The text was updated successfully, but these errors were encountered: