Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Structure Pane/Error Insight    [ Add a report in this area ]  
Report #:  59041   Status: Open
Class Function not identified as Member for metaclass defined prior to base class
Project:  Delphi Build #:  11.0.2902.10471
Version:    11.2 Submitted By:   Lars Fosdal
Report Type:  Basic functionality failure Date Reported:  3/4/2008 4:39:34 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   258288
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 1
Description
Error Insight doesn't seem to recognize class functions as members through class variables if the metaclass is defined before the base class of the metaclass.

It will however compile without hints, warnings or errors.

Ref. the example in the "Steps" section:

type
  TMyClassType = class of TMyClass;

  TMyClass = class(TObject)
    class function id:Integer; virtual;
  end;

generates an error insight error, while

type
  TMyClass = class(TObject)
    class function id:Integer; virtual;
  end;

  TMyClassType = class of TMyClass;

does not generate an error when referring to the class function "id" from a class variable.


Steps to Reproduce:
unit ClassFunctionSyntaxBug;

interface

type
  TMyClassType = class of TMyClass;

  TMyClass = class(TObject)
    class function id:Integer; virtual; // See line 28
  end;

  function MyFactoryCreate(const aClass:TMyClassType):TObject;

implementation

{ TMyClass }

class function TMyClass.id: Integer;
begin
  Result := 1;
end;

function MyFactoryCreate(const aClass:TMyClassType): TObject;
begin
// The "aClass.id" in the line below show as a syntax error in Structure,
// 'TMyClassType' does not contain a member named 'id' at line 28 (28:13)
// but it compiles without errors, hints or warnings:
  if aClass.id <> 0
  then Result := aClass.Create
  else Result := nil;
end;

end.
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01