Open dabrahams opened 1 year ago
Here’s a simpler example producing a different and possibly more insightful stack trace (Swift version 5.8-dev):
protocol P {
associatedtype Element
}
protocol Q<Element>: P {
var element: Element { get }
}
extension Q where Element: Equatable {
func bar() {
_ = self.element
}
}
func foo<T: P>(_ p: T) where T.Element: Equatable {
if let q = p as? any Q<T.Element> {
q.bar()
}
}
struct S: P {
typealias Element = Int
}
func test(s: S) {
foo(s)
}
Compile this with -O for a crash in Swift 5.7.1
Reproduces on Mac and on Linux (godbolt).