Based on @ rintaro's answer, using Self for type defaultValue means typealias not needed:
public protocol Selectable { var selected: Bool { get } static var defaultValue: Self { get } } public func selected<T: Selectable >(items: [T]) -> T { if let selected = items.filter({$0.selected}).first { return selected } return T.defaultValue }
(I found this as changing the defaultValue type to Self , and my implementation class no longer matched the protocol, and I noticed that I didn’t even refer to typealias Value ; deleting, which is why my implementation class matched again).
source share