class A { static func sharedInstance<X: B>(for type: X.Type) -> A { fatalError() } } protocol B { static var a: A { get } } class C: B { static var a: A { return A.sharedInstance(for: C.self) } }