Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Language/Overloading    [ Add a report in this area ]  
Report #:  118123   Status: Closed
Assigning overloaded static class methods to procvars
Project:  Delphi Build #:  19.0.13476.4176
Version:    19.0 Submitted By:   Blaise Thorn
Report Type:  Basic functionality failure Date Reported:  8/22/2013 12:47:15 PM
Severity:    Commonly encountered problem Last Updated: 4/15/2014 6:42:06 PM
Platform:    All platforms Internal Tracking #:   42474
Resolution: Fixed (Resolution Comments) Resolved in Build: : XE6
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 31
Description
Since Delphi 2009, the compiler allows assigning static class methods to procvars, which is quite useful. However, when an OVERLOAD directive is added to such a method (even if no actual overloads are added), the compiler gets confused and reports a bogus E2124 error.

Tags: E2124
Steps to Reproduce:
Notice that this test gets compiled unless you uncomment the OVERLOAD directive. Then, DCC starts reporting bogus E2124.
----------8<----------
type C = class

class procedure Foo(X: Char); {overload;} static;
end;

class procedure C.Foo(X: Char); begin end;

var
R: procedure (X: Char);
begin

R := C.Foo
end.
----------8<----------

Compile this test. Expected: overloads get resolved and assigned. Actual: two bogus E2124. Notice the difference in the reported method names; I wonder the significance.
----------8<----------
type C = class

class procedure Foo(X: Char); overload; static;

class procedure Foo(X: Integer); overload; static;
end;

class procedure C.Foo(X: Char); begin end;

class procedure C.Foo(X: Integer); begin end;

var

R1: procedure (X: Char);

R2: procedure (X: Integer);
begin

R1 := C.Foo;

// BOGUS: E2124 Instance member 'C.Foo' inaccessible here

R2 := C.Foo;

// BOGUS: E2124 Instance member 'Foo' inaccessible here
end.
----------8<----------
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01