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-2796] Generics compiler crash regression #45400
Comments
A smaller example created by creduce-ing `Crasher.swift`: class PropertyDataSource<PropertyHosting> {}
protocol TableViewCellFactoryType {
associatedtype Item
}
protocol PropertyHosting {
associatedtype PType: EntityOwned
}
protocol EntityOwned {
associatedtype Owner
}
class PropertyTableViewAdapter<Factory: TableViewCellFactoryType>
where Factory.Item.Owner: PropertyHosting, Factory.Item.Owner.PType == Factory.Item
{
typealias Item = Factory.Item
let dataManager: PropertyDataSource<Item.Owner>
init(dataManager: PropertyDataSource<Item.Owner>) {
self.dataManager = dataManager
}
} |
Comment by Brian Blanchard (JIRA) I am also having the same issues. I am doing something very similar to @huonw. One thing that I have found, if I turn on whole module optimization the app will build fine but the compiler will seg fault in debug mode. Here is my stack trace:
|
Unfortunately still crashes on master, except the error is different:
|
Still crashes with the latest snapshot (13th Jan 2017), but with `Command failed due to signal: Illegal instruction: 4` |
Yeah, this still needs the new generic signature minimization algorithm that @DougGregor is going to be working on. |
Slightly reduced: protocol P {
associatedtype PType
}
public protocol Q {
associatedtype QType: R
}
public protocol R {
associatedtype RType
}
func f<T: P>(_: T) where T.PType.RType: Q, T.PType.RType.QType == T.PType {} |
I've been looking at this one for a while, and the code itself is ill-formed because it's missing a constraint. Swift 2.x just tolerated it (because of the way it handled "derived" constraints); Swift 3 started relying on well-formed constraints more thoroughly, and the recent refactoring we've done has pushed that reliance earlier in the pipeline. In my reduced example above, we are missing the constraint `T.PType: R`. Without it, there is no way to name `T.PType.RType`. With that constraint (which corresponds to `Factory.Item: EntityOwned` in the original project – which is also missing and should be added!), the project compiles with Xcode 8.3 and master. So... the bug here is that we should be producing an error on this code, either because (1) `RType` does not exist on `T.PType` or (if we realize this is what was intended) because (2) `T.PType` does not conform to `R`. |
In case my above ramble wasn't clear, the code in question should produce an error. Adding the requirement Factory.Item: EntityOwned to class PropertyTableViewAdapter fixes the crash and things seem to work properly. |
GitHub master c063d49 |
This is long done |
Attachment: Download
Environment
macOS Sierra, Xcode Version 8.0 (8A218a), latest Macbook
Additional Detail from JIRA
md5: 3040e439e4846fca8170995cf23cde23
Issue Description:
Similar to SR-2101 which is fixed in the latest snapshot 2016-09-27-a this slightly enhanced example still crashes. I have attached an Xcode project that will immediately crash in Xcode 8 (MAS version) using even that latest snapshot 2016-09-27-a.
Again, this worked without a problem in Swift 2.3 (and is sadly keeping me from adopting Swift 3 in that project so far)
The text was updated successfully, but these errors were encountered: