Fix for Mantis #26483. This regression was introduced by famous revision 27861 which introduced partial specializations (and thus that specializations can be part of local- and parasymtables as well).

symtable.pas, is_visible_for_object:
  * if the symtable belongs to a specialization we need to ignore any owning local- or parasymtable as well to determine which unit it belongs to

+ added test

git-svn-id: trunk@29482 -
This commit is contained in:
svenbarth 2015-01-16 14:23:49 +00:00
parent 7cb38e1ce9
commit 5fd47d5e00
3 changed files with 37 additions and 6 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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
(

24
tests/webtbs/tw26483.pp Normal file
View File

@ -0,0 +1,24 @@
{ %NORUN }
program tw26483;
{$MODE DELPHI}
type
TA<T> = class
private
F: Integer;
end;
TB<T> = class
procedure Foo(A: TObject);
end;
procedure TB<T>.Foo(A: TObject);
begin
WriteLn(TA<T>(A).F); // p004.Error: identifier idents no member "F"
end;
begin
end.