From 86f1ca203746904dafbe6acf0d1dd1f40e5a1def Mon Sep 17 00:00:00 2001 From: svenbarth Date: Sat, 21 Nov 2015 15:52:56 +0000 Subject: [PATCH] symtable.pas, is_visible_for_object: * correctly handle the case that a generic method specialized in another unit needs to have access to private/protected members as well git-svn-id: trunk@32437 - --- compiler/symtable.pas | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/compiler/symtable.pas b/compiler/symtable.pas index 763c664a7f..93807e34b7 100644 --- a/compiler/symtable.pas +++ b/compiler/symtable.pas @@ -2817,6 +2817,8 @@ implementation var symownerdef : tabstractrecorddef; nonlocalst : tsymtable; + isspezproc : boolean; + def : tstoreddef; begin result:=false; @@ -2830,6 +2832,13 @@ implementation if tstoreddef(symst.defowner).is_specialization then while nonlocalst.symtabletype in [localsymtable,parasymtable] do nonlocalst:=nonlocalst.defowner.owner; + isspezproc:=false; + if assigned(current_procinfo) then + begin + if current_procinfo.procdef.is_specialization and + assigned(current_procinfo.procdef.struct) then + isspezproc:=true; + end; case symvisibility of vis_private : begin @@ -2851,6 +2860,12 @@ implementation ( not assigned(current_structdef) and (symownerdef.owner.iscurrentunit) + ) or + { access from a generic method that belongs to the class + but that is specialized elsewere } + ( + isspezproc and + (current_procinfo.procdef.struct=current_structdef) ) ); end; @@ -2919,6 +2934,12 @@ implementation is_objectpascal_helper(contextobjdef) and def_is_related(tobjectdef(contextobjdef).extendeddef,symownerdef) ) + ) or + { access from a generic method that belongs to the class + but that is specialized elsewere } + ( + isspezproc and + (current_procinfo.procdef.struct=current_structdef) ) ); end;