mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 05:08:06 +02:00
* fix #39740: consider a conversion of a procedure or procedure variable to a function reference as a bit more expensive than otherwise
+ added test
This commit is contained in:
parent
492754ecca
commit
2372a06926
@ -2683,6 +2683,14 @@ implementation
|
||||
else
|
||||
eq:=te_incompatible;
|
||||
end;
|
||||
end
|
||||
else if assigned(def2.owner) and
|
||||
assigned(def2.owner.defowner) and
|
||||
is_funcref(tdef(def2.owner.defowner)) then
|
||||
begin
|
||||
{ consider assignment to a funcref a bit more expensive
|
||||
then assigning it to a normal proc or method variable }
|
||||
eq:=te_convert_l2;
|
||||
end;
|
||||
end;
|
||||
proc_to_procvar_equal_internal:=eq;
|
||||
|
@ -2142,7 +2142,7 @@ implementation
|
||||
(m_mac_procvar in current_settings.modeswitches)) and
|
||||
(p.left.nodetype=calln) and
|
||||
is_invokable(def_to) then
|
||||
tmpeq:=proc_to_funcref_equal(tprocdef(tcallnode(p.left).procdefinition),tobjectdef(def_to));
|
||||
tmpeq:=proc_to_funcref_conv(tprocdef(tcallnode(p.left).procdefinition),tobjectdef(def_to));
|
||||
if tmpeq<>te_incompatible then
|
||||
eq:=tmpeq;
|
||||
end;
|
||||
|
34
tests/webtbs/tw39740.pp
Normal file
34
tests/webtbs/tw39740.pp
Normal file
@ -0,0 +1,34 @@
|
||||
{ %NORUN }
|
||||
|
||||
program tw39740;
|
||||
|
||||
{$mode delphi}
|
||||
{$modeswitch FUNCTIONREFERENCES}
|
||||
uses classes;
|
||||
|
||||
|
||||
{$if not declared(TThreadProcedure)}
|
||||
type
|
||||
TThreadProcedure = reference to procedure;
|
||||
{$endif}
|
||||
|
||||
procedure bla(t : tthreadmethod); overload;
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure bla(t : tthreadprocedure); overload;
|
||||
begin
|
||||
end;
|
||||
|
||||
type ta = class
|
||||
procedure bla;
|
||||
end;
|
||||
|
||||
procedure ta.bla;
|
||||
begin
|
||||
end;
|
||||
var a : Ta;
|
||||
begin
|
||||
bla(a.bla);
|
||||
// bla(tthreadmethod(a.bla)); // works
|
||||
end.
|
Loading…
Reference in New Issue
Block a user