Well, my other post from today happens to give a solution
although I am not satisfied with that yet.
https://forum.lazarus.freepascal.org/index.php/topic,67624.msg520956/topicseen.html#newThat code works and would also work in this case.
(It can transparently create instances of classes that support an interface or treat an
initialized interface as an instance)
But now he writes that
he has no control over the interfaces and that is actually a complicating matter.
What is definitely wrong is the way he uses that record.
IF there is an instance, he would call Supports() to know if a particular class instance supports that interface.
Storing the interface instead of the class reference will never work.
He can do something like this:
TInfo = record
Name: String;
Inst: TSomeImplementer;
end;
and use
is and
as and
supports.
But there needs to be at least a pointer to a genuine
instance.