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-4315] Xcode 8.3 compiler crashes on generic subclass init #46898
Comments
Comment by Adam Newton (JIRA) The subscript part of this is potentially related to https://bugs.swift.org/browse/SR-3547 |
Comment by Adam Newton (JIRA) One of my teammates found the following workaround: final class InteractiveAPICall<Document: ParsableResult, Parser: SAXParsable>:
XMLSAXElementParser<XMLElementsNone, ResultElement<Parser>> {
}
extension InteractiveAPICall where Document.Parser == Parser {
func result() throws -> Document {
/// With the following code block commented out, the compiler crashes in SILGen
/// If you uncomment the block, it errors with "ambiguous reference to member 'subscript'"
let childKey = ResultElement<Parser>()
let parser: [SAXParsable]? = self.children[childKey]
if let resultParser = parser?.first as? Parser {
return try Document(parser: resultParser)
}
throw InteractiveAPIError.malformedResult
}
} Looks like moving |
@swift-ci create |
I cannot reproduce this with the latest 3.1 development snapshot. |
Sorry, operator error. It reproduces on the latest 3.1 snapshot:
|
It also builds successfully on master. |
I think it's a case of https://bugs.swift.org/browse/SR-3045 (the general problem remains but this manifestation appears to be fixed). |
So I added a regression test for this to master that ensures the code will continue to work there. The workaround in 3.1 is to not define generic parameters which are same-type constrained to an associated type. That is,
can be written as
And instead of using the generic parameter 'Parser' in the body, you just write 'Document.Parser' instead. |
Attachment: Download
Environment
Xcode 8.3 8E161. macOS 10.12.3 (16D32)
Additional Detail from JIRA
md5: f520d9ba7bad66fb4552766ea0333f42
is duplicated by:
Issue Description:
I have a class that inherits from a generic class in a separate module. I'm seeing 2 new issues in Xcode 8.3 that were not present in Xcode 8.2.1
1. When trying to access a dictionary property of the superclass, the compiler can't infer which subscript to use
2. When I comment out the dictionary access, SILGen crashes.
I have attached a minimized repro project.
The text was updated successfully, but these errors were encountered: