Missing warning?

Missing warning?

type

  TMyClass = class abstract (TObject)

     // Lots of methods, but none of them abstract;

  end;

  TMyImplementedClass = class(TMyClass)

    // Overrides some of the parent methods and adds new ones

   end;

var

   TFoo: TMyClass;

begin

   TFoo := TMyClass.Create;  *// WHAT!? No Warnings!?*

 

The XE2 to XE7 documentation states…

http://docwiki.embarcadero.com/RADStudio/XE7/en/Classes_and_Objects

states “Note: Delphi allows instantiating a class declared abstract, for backward compatibility, but this feature should not be used anymore.” – which is all dandy, but not issuing a warning for such use, that seems wrong to me.

Interestingly, the XE version is different…

http://docwiki.embarcadero.com/RADStudio/XE/en/Classes_and_Objects

and says “If a class is marked abstract, then it cannot be instantiated directly using the Create constructor. “

When did they introduce this keyword – and why did they not stick with the XE design?  Go figure…

Is there a QP or QC for this?

13 thoughts on “Missing warning?


  1. David Millington Some things are fundamental, and need attention in the compiler. This would seem to be one of those. Really, this should be cause for embarrassment.


  2. Bill Meyer True. But I’m sure Roman is looking out for useful checks he can add. Plus, he adds things to FixInsight faster than we get new compiler releases :p


  3. Only different between XE and XE2 to XE7 is: The documentation was updated. You are still able to instatiate a abstact class in XE 🙁


  4. Stefan Glienke – IMO, it needs to at least output a warning.  Isn’t the whole idea of an abstract class, that it simply is a “template” for actual implementations to inherit from?

Leave a Reply