mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-06 23:46:04 +02:00
* set the type symbol of the procvar while it is parsed so that a function reference can have itself as part of the parameters or the return type
This commit is contained in:
parent
06a00b53c3
commit
6299e94c8f
@ -1562,13 +1562,14 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
function procvar_dec(genericdef:tstoreddef;genericlist:tfphashobjectlist;doregister:boolean):tdef;
|
||||
function procvar_dec(genericdef:tstoreddef;genericlist:tfphashobjectlist;sym:tsym;doregister:boolean):tdef;
|
||||
var
|
||||
is_func:boolean;
|
||||
pd:tprocvardef;
|
||||
old_current_genericdef,
|
||||
old_current_specializedef: tstoreddef;
|
||||
old_parse_generic: boolean;
|
||||
olddef : tdef;
|
||||
begin
|
||||
old_current_genericdef:=current_genericdef;
|
||||
old_current_specializedef:=current_specializedef;
|
||||
@ -1581,6 +1582,13 @@ implementation
|
||||
consume(token);
|
||||
pd:=cprocvardef.create(normal_function_level,doregister);
|
||||
|
||||
if assigned(sym) then
|
||||
begin
|
||||
pd.typesym:=sym;
|
||||
olddef:=ttypesym(sym).typedef;
|
||||
ttypesym(sym).typedef:=pd;
|
||||
end;
|
||||
|
||||
{ usage of specialized type inside its generic template }
|
||||
if assigned(genericdef) then
|
||||
current_specializedef:=pd
|
||||
@ -1640,6 +1648,12 @@ implementation
|
||||
current_genericdef:=old_current_genericdef;
|
||||
current_specializedef:=old_current_specializedef;
|
||||
|
||||
if assigned(sym) then
|
||||
begin
|
||||
pd.typesym:=nil;
|
||||
ttypesym(sym).typedef:=olddef;
|
||||
end;
|
||||
|
||||
result:=pd;
|
||||
end;
|
||||
|
||||
@ -1952,7 +1966,7 @@ implementation
|
||||
_PROCEDURE,
|
||||
_FUNCTION:
|
||||
begin
|
||||
def:=procvar_dec(genericdef,genericlist,true);
|
||||
def:=procvar_dec(genericdef,genericlist,nil,true);
|
||||
{$ifdef jvm}
|
||||
jvm_create_procvar_class(name,def);
|
||||
{$endif}
|
||||
@ -1982,7 +1996,7 @@ implementation
|
||||
consume(_TO);
|
||||
{ don't register the def as a non-cblock function
|
||||
reference will be converted to an interface }
|
||||
def:=procvar_dec(genericdef,genericlist,false);
|
||||
def:=procvar_dec(genericdef,genericlist,newsym,false);
|
||||
{ could be errordef in case of a syntax error }
|
||||
if assigned(def) and
|
||||
(def.typ=procvardef) then
|
||||
|
Loading…
Reference in New Issue
Block a user