diff --git a/.gitattributes b/.gitattributes index d2f8892247..5de729af2c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14149,6 +14149,7 @@ tests/webtbs/tw2645.pp svneol=native#text/plain tests/webtbs/tw26467.pp svneol=native#text/pascal tests/webtbs/tw2647.pp svneol=native#text/plain tests/webtbs/tw26482.pp svneol=native#text/pascal +tests/webtbs/tw26483.pp svneol=native#text/pascal tests/webtbs/tw2649.pp svneol=native#text/plain tests/webtbs/tw2651.pp svneol=native#text/plain tests/webtbs/tw26536.pp svneol=native#text/plain diff --git a/compiler/symtable.pas b/compiler/symtable.pas index 970ec4ce5f..600ea9f18e 100644 --- a/compiler/symtable.pas +++ b/compiler/symtable.pas @@ -2211,6 +2211,7 @@ implementation function is_visible_for_object(symst:tsymtable;symvisibility:tvisibility;contextobjdef:tabstractrecorddef):boolean; var symownerdef : tabstractrecorddef; + nonlocalst : tsymtable; begin result:=false; @@ -2219,17 +2220,22 @@ implementation not (symst.symtabletype in [objectsymtable,recordsymtable]) then internalerror(200810285); symownerdef:=tabstractrecorddef(symst.defowner); + { specializations might belong to a localsymtable or parasymtable } + nonlocalst:=symownerdef.owner; + if tstoreddef(symst.defowner).is_specialization then + while nonlocalst.symtabletype in [localsymtable,parasymtable] do + nonlocalst:=nonlocalst.defowner.owner; case symvisibility of vis_private : begin { private symbols are allowed when we are in the same module as they are defined } result:=( - (symownerdef.owner.symtabletype in [globalsymtable,staticsymtable]) and - (symownerdef.owner.iscurrentunit) + (nonlocalst.symtabletype in [globalsymtable,staticsymtable]) and + (nonlocalst.iscurrentunit) ) or ( // the case of specialize inside the generic declaration and nested types - (symownerdef.owner.symtabletype in [objectsymtable,recordsymtable]) and + (nonlocalst.symtabletype in [objectsymtable,recordsymtable]) and ( assigned(current_structdef) and ( @@ -2281,8 +2287,8 @@ implementation in the current module } result:=( ( - (symownerdef.owner.symtabletype in [globalsymtable,staticsymtable]) and - (symownerdef.owner.iscurrentunit) + (nonlocalst.symtabletype in [globalsymtable,staticsymtable]) and + (nonlocalst.iscurrentunit) ) or ( assigned(contextobjdef) and @@ -2291,7 +2297,7 @@ implementation def_is_related(contextobjdef,symownerdef) ) or ( // the case of specialize inside the generic declaration and nested types - (symownerdef.owner.symtabletype in [objectsymtable,recordsymtable]) and + (nonlocalst.symtabletype in [objectsymtable,recordsymtable]) and ( assigned(current_structdef) and ( diff --git a/tests/webtbs/tw26483.pp b/tests/webtbs/tw26483.pp new file mode 100644 index 0000000000..3da391e327 --- /dev/null +++ b/tests/webtbs/tw26483.pp @@ -0,0 +1,24 @@ +{ %NORUN } + +program tw26483; + +{$MODE DELPHI} + +type + TA = class + private + F: Integer; + end; + + TB = class + procedure Foo(A: TObject); + end; + +procedure TB.Foo(A: TObject); +begin + WriteLn(TA(A).F); // p004.Error: identifier idents no member "F" +end; + +begin +end. +