I haven't seen this specific pattern of protocol extension elsewhere, but it works in a playground and does what I need it to do — extending one protocol to provide an implementation of another protocol it inherits with typealias requirements. Simple example:
protocol TreeNode: SequenceType {
var children: Array<Self> { get set }
}
extension SequenceType where Self: TreeNode, Generator == AnyGenerator<Self> {
func generate() -> Generator {
return anyGenerator(children.generate())
}
}Issue comes when it's dropped into a project. If it's the only thing in the project, it'll compile fine. However, I can drop seemingly innocuous code (not in any way interacting with the above) into another file and the project segfaults on compile.
Example of innocuous code for another file:
struct IntWrapper {
let anInt: Int = 0
}This compiles fine without the presence of the above.
Better way to accomplish the same? Suggestions for troubleshooting the segfault?