Jump to content
pyscripter

Question: Is there a way to tell whether a method is overloaded using rtti?

Recommended Posts

As per title.

 

For instance:

 

A)  Second method hides the first

 

ClassA = class
  procedure Test(I: Integer);
end;

ClassB = class(classA)
  procedure Test(S: string);
end;

 

B)  Second method overloads the first
 

ClassA = class
  procedure Test(I: Integer); overload;
end;

ClassB = class(classA)
  procedure Test(S: string); overload;
end;

 

How can you tell the difference with Rtti.  GetMethods would show both methods in a similar way.

Edited by pyscripter

Share this post


Link to post

Yes and no.

The overloaded methods will be listed one by one with the same name in getmethods but only the public ones.

 

Edited by Attila Kovacs

Share this post


Link to post
12 minutes ago, Attila Kovacs said:

The overloaded methods will be listed one by one

But so do overwritten methods, virtual methods etc.

Share this post


Link to post

hm, right. I think virtual / overriden having a DispatchKind of dkVtable and overwitten different parent.

A bit of puzzle.

Share this post


Link to post

No, RTTI does not contain any flag for a method being overloaded which makes it impossible to do proper overload resolution using RTTI because you cannot determine if a method would be "visible" or not.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×