protocol P { var p: Int { get } } extension P where Self: A { var p: Int { return self.p * 2 } } class A {} extension A: P {} let instance = A() print(instance.p)