Log On
Embarcadero Home
Watch, Follow, &
Connect with Us
Share This
QualityCentral
Communities
Articles
Blogs
Resources
Downloads
Help
QualityCentral
Delphi-BCB
Compiler
Delphi
Language
Overloading
Global
Method
You are not logged in.
Help
Print
Public Report
Report From:
Delphi-BCB/Compiler/Delphi/Language/Overloading/Method
[ Add a report in this area ]
Report #:
3016
Status:
Closed
Overloaded with different visibility method does not compile
Project:
Delphi
Build #:
2195
Version:
6.0
Submitted By:
Andrei Asayonak
Report Type:
Minor failure / Design problem
Date Reported:
11/28/2002 8:33:26 AM
Severity:
Infrequently encountered problem
Last Updated:
1/22/2006 10:40:52 AM
Platform:
All versions
Internal Tracking #:
Resolution:
Fixed
(Resolution Comments)
Resolved in Build:
:
10.0.2166
Duplicate of:
None
Voting and Rating
Overall Rating:
(6 Total Ratings)
4.17 out of 5
Total Votes:
1
Description
When a class's method is overloaded with different visibility: ...
public
procedure CacheTable; overload; virtual;
protected
procedure CacheTable(tName : string); overload;
...
compiler generates "Undeclared identifier" error, if the method is called from outside the class.
I give this report Severity 1, because it may indicate some fundamental flaw in how ObjectPascal code is interpreted/generated.
Steps to Reproduce:
1. File-New-Application (for simplicity)
2. Add another unit
3. Adjust the generated form definition, so the files look like this:
//--------------------------------------------------------------------------------------------------------------------/
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Contnrs, DBTables;
type
TForm1 = class(TForm)
private
public
end;
type
TCachingObjectList = class (TObjectList)
public
TableName : string;
constructor Create(tName : string);
procedure CacheTable; overload; virtual;
protected
procedure CacheTable(tName : string); overload;
end;
TTaskInfoList = class (TCachingObjectList)
public
function getTaskInfo(taak_nr : string) : TObject;
end;
var
Form1: TForm1;
TaskInfoList : TTaskInfoList;
implementation
{$R *.dfm}
{ TCachingObjectList }
procedure TCachingObjectList.CacheTable(tName: string);
begin
end;
procedure TCachingObjectList.CacheTable;
begin
CacheTable(TableName);
end;
constructor TCachingObjectList.Create(tName: string);
begin
inherited Create;
TableName := tName;
end;
{ TTaskInfoList }
function TTaskInfoList.getTaskInfo(taak_nr: string): TObject;
begin
result := nil;
end;
initialization
TaskInfoList := TTaskInfoList.Create('aaa');
finalization
TaskInfoList.Free;
end.
//--------------------------------------------------------------------------------------------------------------------/
unit Unit2;
interface
uses Unit1;
procedure proc;
implementation
procedure proc;
begin
//TaskInfoList.CacheTable;
end;
end.
//--------------------------------------------------------------------------------------------------------------------/
Note, the commented out text in Unit2.
This should compile with no problems.
4. Now go to Unit2 and uncomment the line. Code wont compile any more, giving "Undeclared identifier:CacheTable" error.
Workarounds
This can be strange but it worked for me:
I moved the CacheTable overloaded method to the "public" section:
...
public
procedure CacheTable; overload; virtual;
procedure CacheTable(tName : string); overload;
protected
...
and code compiled with no problems. And then (!!!!!) I moved it back to the protected section,
...
public
procedure CacheTable; overload; virtual;
protected
procedure CacheTable(tName : string); overload;
...
and recompiled with no problems!
Attachment
None
Comments
Andrei Asayonak at 11/28/2002 8:35:34 AM
-
Btw, Code completion displays the method in its pop-up list, so Code completion realisis I should be able to use it, but compiler does not.
Stefan Hoffmeister at 11/28/2002 11:18:17 AM
-
Adjusted severity and type.
Robert Lee at 3/11/2003 5:34:34 AM
-
Confirmed in D7
Kjell Rilbe at 5/27/2004 6:05:54 AM
-
In some ways this sounds like it could be realted to 3077 "under the hood".
View Your Reports
Search
Server Response from: ETNACODE01
Developer Tools
Blackfish SQL
C++Builder
Delphi
FireMonkey
Prism
InterBase
JBuilder
J Optimizer
HTML5 Builder
3rdRail & TurboRuby
Database Tools
Change Manager
DBArtisan
DB Optimizer
ER/Studio
Performance Center
Rapid SQL
Technical Articles
Tutorials
White Papers
Press Releases
Newsletters
Add Content (GetPublished)
Audio
Audio & Video
Video
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Tags
Technology Partners
Downloads
Free Trials
Registered User Downloads
Beta Programs
Add Content (GetPublished)
Articles
Blogs
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Member Services
About
Connect with Us