<div dir="ltr"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
<span style="color:rgb(34,34,34)">I suggest a modification to your example:</span><br></div>Please observe this: <a href="http://pastebin.com/9axN51QE" target="_blank">http://pastebin.com/9axN51QE</a><br>If you declare a base class with "reintroduced" constructor (like I suggest) then you may prevent FreePascal compiler from "seeing" TObject.Create constructor. Therefore it will determine which constructor to call; so you won't get a compiler error in this example. I think that the fact that it can not determine which constructor to call when TObject.Create overloaded constructor is in scope is just logical; it should work this way. However if Delphi compiler uses a different kind of logic here then perhaps we can call it a bug; but only for Delphi mode; while ObjFPC mode should be left unchanged considering this particular problem.</blockquote>
</div></div><div><br></div>The main problem is:<div><br></div><div>1. The error is not only about constructors</div><div><br></div><div>2. Reintroduce does not solve the problem</div><div><br></div><div>3. TObject.Create, shouldn't be visible in any way from TB (where is visible - and this is a bug. Is visible, but you can call it in any way) and TA level. Sadly when we calling the constructor for TB, TObject.Create is still visible (only when there exist default value for parameter in TA) - but sould be hidden for ever at TA leve, for any TA child. Following by current logic, this example should not compile:</div>
<div><br></div><div>------begin code------</div><div>TA = class</div><div> procedure Foo;</div><div>end;</div><div><br></div><div>TB = class(TA)</div><div> procedure Foo(A: Integer = 0); overload;</div><div>end;</div><div>
<br></div><div>var</div><div> b: TB;</div><div>begin</div><div> b := TB.Create;</div><div> b.Foo; // should raise Error: Can't determine which overloaded function to call</div><div>end;</div><div>------end code------</div>
<div><br></div><div>I want use ObjFPC too :) I see any single reson to don't fixing this... No side effects. </div><div><br></div><div>Returning to the example from bugtracker (<a href="http://bugs.freepascal.org/view.php?id=25607">http://bugs.freepascal.org/view.php?id=25607</a>):<br>
</div><div>FPC don't recognize at TB level that the TObject.Create was hidden on the TA level by </div><div><br></div><div>constructor Create(A: Integer = 0); virtual; overload;</div><div><br></div><div>Regards,</div>
<div>HNB</div></div>