* fix #39736: ensure that the capturer object and any converted function reference interface are considered used

+ added test
This commit is contained in:
Sven/Sarah Barth 2022-05-27 07:24:46 +02:00
parent 02211971a3
commit f73fc7d566
2 changed files with 30 additions and 0 deletions

View File

@ -334,6 +334,7 @@ implementation
symowner.insertsym(sym);
symowner.insertdef(result);
addsymref(sym);
end;
@ -446,6 +447,7 @@ implementation
typesym.fileinfo:=pd.fileinfo;
st.insertdef(def);
st.insertsym(typesym);
addsymref(typesym);
if df_generic in pd.defoptions then
include(def.defoptions,df_generic);

28
tests/webtbs/tw39736.pp Normal file
View File

@ -0,0 +1,28 @@
{ %NORUN }
program tw39736;
{$mode objfpc}{$H+}
{$ModeSwitch functionreferences}
{$ModeSwitch anonymousfunctions}
{$warn 5028 error}
type
TProc = reference to procedure;
var
p: TProc;
procedure Fly(w: word);
begin
p:=procedure
begin
writeln('TBird.Fly w=',w);
end;
p();
end;
begin
Fly(3);
end.