<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Martin Frb via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>> schrieb am Do., 9. Dez. 2021, 00:15:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<a href="https://gitlab.com/freepascal.org/fpc/source/-/issues/39459" target="_blank" rel="noreferrer">https://gitlab.com/freepascal.org/fpc/source/-/issues/39459</a><br>
You wrote<br>
>> No, this can not and this will never work. When a generic
parameter has a constraint that constraint <em>must</em> be adhered
to and a forward declaration is <em>not</em> a valid type for such
a constraint (except for <strong>class</strong> / <code>TObject</code>
constraints).<br>
<br>
Using TObject for just any class is nice here.<br>
<br>
What to use for interface?<br>
<a href="https://gitlab.com/freepascal.org/fpc/source/-/issues/39459#note_758496897" target="_blank" rel="noreferrer">https://gitlab.com/freepascal.org/fpc/source/-/issues/39459#note_758496897</a><br>
<br>
Sorry replied on the wrong issue.<br>
<br>
<br>
How can I restrain a generic param, so it must be an interface, but
leave open the exact type, so I can later use a forward declaration?<br></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">For interfaces you can use IInterface/IUnknown though that will work only for COM interfaces. For raw interfaces there is no solution currently. </div><div dir="auto"><br></div><div dir="auto">In my opinion you should rethink your code structure however. I don't know right now what would be better, but as it is now it feels bad. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div></div>
</blockquote></div></div></div>