* fixed calling static TP-style object methods from within other methods

(mantis #16954)

git-svn-id: trunk@15598 -
This commit is contained in:
Jonas Maebe 2010-07-18 11:01:12 +00:00
parent e881e4aa22
commit b18a4617bb
3 changed files with 57 additions and 20 deletions

1
.gitattributes vendored
View File

@ -10546,6 +10546,7 @@ tests/webtbs/tw16874.pp svneol=native#text/plain
tests/webtbs/tw16901.pp svneol=native#text/plain
tests/webtbs/tw16949a.pp svneol=native#text/plain
tests/webtbs/tw16949b.pp svneol=native#text/plain
tests/webtbs/tw16954.pp svneol=native#text/plain
tests/webtbs/tw1696.pp svneol=native#text/plain
tests/webtbs/tw1699.pp svneol=native#text/plain
tests/webtbs/tw1709.pp svneol=native#text/plain

View File

@ -1508,29 +1508,25 @@ implementation
is_object(hdef) then
begin
consume(_POINT);
{ handles calling methods declared in parent objects
using "parentobject.methodname()" }
if assigned(current_objectdef) and
not(getaddr) then
begin
if current_objectdef.is_related(tobjectdef(hdef)) then
begin
p1:=ctypenode.create(hdef);
{ search also in inherited methods }
searchsym_in_class(tobjectdef(hdef),current_objectdef,pattern,srsym,srsymtable);
if assigned(srsym) then
check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
consume(_ID);
do_member_read(tobjectdef(hdef),false,srsym,p1,again,[]);
end
else
begin
Message(parser_e_no_super_class);
again:=false;
end;
end
not(getaddr) and
current_objectdef.is_related(tobjectdef(hdef)) then
begin
p1:=ctypenode.create(hdef);
{ search also in inherited methods }
searchsym_in_class(tobjectdef(hdef),current_objectdef,pattern,srsym,srsymtable);
if assigned(srsym) then
check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
consume(_ID);
do_member_read(tobjectdef(hdef),false,srsym,p1,again,[]);
end
else
begin
{ allows @TObject.Load }
{ also allows static methods and variables }
{ handles:
* @TObject.Load
* static methods and variables }
p1:=ctypenode.create(hdef);
{ TP allows also @TMenu.Load if Load is only }
{ defined in an anchestor class }

40
tests/webtbs/tw16954.pp Normal file
View File

@ -0,0 +1,40 @@
program project_static2;
type
Etyp=(t1,t2,t3);
type
ProxyObject=object
function IsInSubrange(const typ:Etyp):boolean;static;
end;
RealObject=object
mytyp:Etyp;
function IsInSubrange:boolean;
end;
function RealObject.IsInSubrange: boolean;
begin
IsInSubrange:=ProxyObject.IsInSubrange(mytyp);
// ^-- Error: Class isn't a parent class of the current class
// and AV of compiler
end;
function ProxyObject.IsInSubrange(const typ: Etyp): boolean;
begin
IsInSubrange:=typ<=t2;
end;
var o:RealObject;
begin
if ProxyObject.IsInSubrange(t3) then
halt(1);
if not ProxyObject.IsInSubrange(t2) then
halt(2);
o.mytyp:=t3;
if o.isInSubRange then
halt(3);
o.mytyp:=t1;
if not o.isInSubRange then
halt(4);
end.