Bug in TRttiTypeHelper

Issue #21 new
Former user created an issue

Hi,

I found different linked problems in RttiTypeHelper :

I have the inheritance schemes :

TForm | TBaseForm<T> = class(TForm) | TForm2 = class(TBaseForm(TTest))

If I have the TRttiType of TForm2 :

  • The method IsGenericTypeDefinition will return true
  • The method GetGenericTypeDefinition will return '<' has ExtractGenericArguments will return empty args
  • The method GetGenricArguments will return TTest

=> This is a first inconsistency. Either all method on generics should try on the ancestor (BaseType), either none.

And if you are testing ItCovariantTo(TForm) then you will have an access violation. This is because IsGenericTypeDefinition will return true, SameText(GetGenericTypeDefinition, t.GetGenericTypeDefinition) will return true has the two will return '<' and otherArgs[i] will not exists has TForm has no arguments and no generic ancestor ...

I will add that in IsCovariantTo you've got an error : if args[i].IsInterface and args[i].IsInterface and args[i].InheritsFrom(otherArgs[i].Handle) then begin Continue; end;

should be : if args[i].IsInterface and otherArgs[i].IsInterface and args[i].InheritsFrom(otherArgs[i].Handle) then begin Continue; end;

Comments (0)

  1. Log in to comment