RefCount isn't handled correctly if guid 0, obviously tests were for guid 0 only (either when I create guid with md5 or specify in interface type as {C35224FA-ED88-0D1C-A4D2-FCF91AC4C8C6})
// always using same two variables, and notice all possible calls
// do the same error with counting one too much
obj := TSomeClass.Create;
Writeln('ref:', (obj as TInterfacedObject).RefCount); //count=0
a := obj; aa := (a as IA);
Writeln('ref:', (obj as TInterfacedObject).RefCount); //count=3
a := obj;
Supports(a, IA, aa);
obj.GetInterface(IA, aa);
obj.GetInterface(IA, aa);
obj.GetInterface(IA, aa);
Writeln('ref:', (obj as TInterfacedObject).RefCount); //count=7OUTPUT:
TSomeClass.Create
ref:0
ref:3
ref:7
Just as soon as you apply simple patch (included), everything works like it should
OUTPUT (after patch):
TSomeClass.Create
ref:0
ref:2
ref:2
