How to create resolution clauses for overloaded interface methods?
delphi, interface
Solution
Your question stated the answer:
parameter lists are not allowed in method resolution clauses
Parameter lists are necessary for resolving overloads, and since you can't specify parameter lists in method resolution clauses, you cannot use method resolution clauses for overloaded methods. There is no syntax to support what you are asking for.
Problem
Let's say I have an interface like this one: ``` IMaker = interface function Make(const Int: Integer): IInterface; overload; function Make(const Str: String): IInterface; overload; end; ``` The common way to implement this interface looks like this: ``` TMaker = class(TInterfacedObject, IMaker) public function Make(const Int: Integer): IInterface; overload; function Make(const Str: String): IInterface; overload; end; ``` But what if I want to use method resolution clauses for some reasons? My first guess looks like this: ``` TMaker = class(TInterfacedObject, IMaker) private function MakeByInt(const Int: Integer): IInterface; function MakeByStr(const Str: String): IInterface; public function IMaker.Make(const Int: Integer) = MakeByInt; function IMaker.Make(const Str: String) = MakeByStr; end; ``` This code doesn't compile since parameter lists are not allowed in method resolution clauses. How does the syntax look like in this case? Is it even possible to use method resolution clauses for overloaded methods?