Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Documentation/Online Help    [ Add a report in this area ]  
Report #:  24662   Status: Open
Keyword "abstract" for classes does not work in D2006.pro.win32
Project:  Delphi Build #:  2006, ... XE2
Version:    16.4 Submitted By:   Dimitry Timokhov
Report Type:  Documentation problem Date Reported:  2/8/2006 12:28:52 PM
Severity:    Commonly encountered problem Last Updated: 8/2/2012 1:06:45 AM
Platform:    All versions Internal Tracking #:  
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (3 Total Ratings)
4.67 out of 5
Total Votes: 21
Description
Added by Sysop
<<<<<<<
This is a documentation problem.  The creation of an abstract class is allowed.
Compiles (although it shouldn't) in Delphi XE2.
>>>>>>>


This code in delphi2006 for win 32 can be compiled with no error.

unit Unit1;

interface

type
  TMyClass = class abstract
  end;

implementation

procedure MyProc();
var
   kM: TMyClass;
begin
   kM := TMyClass.Create();
end;

end.


But in manual I see this:

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

I Is likly a problem.
Steps to Reproduce:
1. Compile this in delphi2006 for win32:

unit Unit1;

interface

type
  TMyClass = class abstract
  end;

implementation

procedure MyProc();
var
   kM: TMyClass;
begin
   kM := TMyClass.Create(); // error must be here!
end;

end.

2. There is no compile error. But manual says that this code can't be compiled.
Workarounds
None
Attachment
None
Comments

Dimitry Timokhov at 6/30/2006 10:30:22 PM -
Is my report not about bug?

Michael Heydon at 12/1/2008 1:49:14 AM -
I think it is partially implemented for some unknown reason? It works in Delphi .NET, but not in Delphi Win32.

Primoz Gabrijelcic at 11/28/2008 11:28:16 PM -
I think it is a bug. Or an non-implemented feature.

Still compiles (although it shouldn't) in D2007 and D2009.

Didier Cabalé at 8/2/2012 12:28:26 AM -
Compiles (although it shouldn't) in Delphi XE2

Michael Heydon at 12/1/2008 1:42:21 AM -
I agree with you, if the keyword is implemented then it should work as documented. It would not cause any backward compatability as only methods were allowed to be abstract before and this only resulted in a compiler warning anyhow. The "class abstract" should PROHIBIT the creation of a class at compile time. This bug also explains the "class abstract sealed" contradiction that is reported on the web. Since no action is taken with "class abstract" the contradiction will compile OK. The fact that this problem is propogated in D2009 is a little concerning.

Tomohiro Takahashi at 8/2/2012 1:06:49 AM -
This is a documentation problem.  The creation of an abstract class is allowed.

This report was opened.
But, Internal Tracking Number field is still blank.

Didier Cabalé at 8/9/2012 12:34:24 AM -
Tomohiro,

> This is a documentation problem.

not only ..

> The creation of an abstract class is allowed.

yes, it is allowed, but it does not provide any additional behaviour to the class -> it seems that 'abstract class' are simply not implemented.

Didier Cabalé at 8/9/2012 12:57:54 AM -
I precise: instead of writing "it does not provide ..", I should have written "the declaration of an abstract class does not provide any additional behaviour vs a standard class"

Server Response from: ETNACODE01