mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 16:19:35 +02:00
* fix #39977: allow a capturer to access any method independant of visibility as the visibility checks are supposed to have been done before the captured symbol was converted
+ added test
This commit is contained in:
parent
b051e7667c
commit
9e3483fbeb
@ -3355,6 +3355,15 @@ implementation
|
||||
else
|
||||
internalerror(2019050702);
|
||||
end;
|
||||
|
||||
if not result then
|
||||
begin
|
||||
{ capturers have access to anything as we assume checks were done
|
||||
before the procdef was inserted into the capturer }
|
||||
result:=assigned(current_structdef) and
|
||||
(current_structdef.typ=objectdef) and
|
||||
(oo_is_capturer in tobjectdef(current_structdef).objectoptions);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
49
tests/webtbs/tw39977.pp
Normal file
49
tests/webtbs/tw39977.pp
Normal file
@ -0,0 +1,49 @@
|
||||
{ %NORUN }
|
||||
|
||||
program tw39977;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$mode delphi}
|
||||
{$ModeSwitch functionreferences}
|
||||
{$ELSE}
|
||||
{$APPTYPE CONSOLE}
|
||||
{$ENDIF}
|
||||
|
||||
type
|
||||
TRefProc = reference to procedure(Sender: TObject);
|
||||
|
||||
procedure Test(P: TRefProc);
|
||||
begin
|
||||
Writeln('test');
|
||||
end;
|
||||
|
||||
type
|
||||
TMyObjA = class(TObject)
|
||||
strict protected
|
||||
procedure MyEvent(Sender: TObject);
|
||||
end;
|
||||
|
||||
TMyObjB = class(TMyObjA)
|
||||
public
|
||||
procedure MyTest;
|
||||
end;
|
||||
|
||||
{ TMyObjA }
|
||||
procedure TMyObjA.MyEvent(Sender: TObject);
|
||||
begin
|
||||
Writeln('hello');
|
||||
end;
|
||||
|
||||
{ TMyObjB }
|
||||
procedure TMyObjB.MyTest;
|
||||
begin
|
||||
Test(MyEvent); // solved with ObjFpc mode and Test(@MyEvent); using Self.MyEvent or TRefProc(MyEvent) doesn't help
|
||||
end;
|
||||
|
||||
var
|
||||
O: TMyObjB;
|
||||
begin
|
||||
O := TMyObjB.Create;
|
||||
O.MyTest;
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user