Files
swift-mirror/validation-test/compiler_crashers_fixed/0137-issue-49279.swift
Hamish Knight 4e811c3a88 [test] Merge crasher directories
There is no longer much of a good reason to keep these separate,
merge them.
2025-10-18 12:51:30 +01:00

45 lines
729 B
Swift

// RUN: not %target-swift-frontend %s -typecheck
// https://github.com/apple/swift/issues/49279
public protocol OptionalProtocol {
associatedtype Wrapped
var optional: Wrapped? { get }
}
extension Optional: OptionalProtocol {
public var optional: Wrapped? {
return self
}
}
public extension Sequence where Element: OptionalProtocol {
func skipNil() -> [Element.Wrapped] {
return self
.compactMap { $0.optional }
}
}
class A {}
class A1: A {}
class A2: A {}
class A3: A {}
final class V {
init() {
([
self.a1, self.a2, self.a3
] as [A])
.skipNil()
.forEach { self.f($0) }
}
func f(_ a: A) {}
private let a1 = A1()
private let a2 = A2()
private let a3 = A3()
}