protocol A { associatedtype B = String func hello() -> B } extension A where B == String { func hello() -> B { return "hello" } } extension A where B == Int { func hello() -> Int { return 1 } } class C: A { } C().hello()