* fix for Mantis #31431: allow specializations to allow private/protected variables that their generic could have accessed

git-svn-id: trunk@35510 -
This commit is contained in:
svenbarth 2017-03-03 21:45:29 +00:00
parent 5426c11611
commit 7dc4f16db3
4 changed files with 56 additions and 0 deletions

2
.gitattributes vendored
View File

@ -15387,6 +15387,7 @@ tests/webtbs/tw31332.pp svneol=native#text/pascal
tests/webtbs/tw3137.pp svneol=native#text/plain
tests/webtbs/tw31421a.pp svneol=native#text/plain
tests/webtbs/tw3143.pp svneol=native#text/plain
tests/webtbs/tw31431.pp svneol=native#text/pascal
tests/webtbs/tw3144.pp svneol=native#text/plain
tests/webtbs/tw3157.pp svneol=native#text/plain
tests/webtbs/tw3160a.pp svneol=native#text/plain
@ -16055,6 +16056,7 @@ tests/webtbs/uw2920.pp svneol=native#text/plain
tests/webtbs/uw2956.pp svneol=native#text/plain
tests/webtbs/uw2984.pp svneol=native#text/plain
tests/webtbs/uw3103.pp svneol=native#text/plain
tests/webtbs/uw31431.pp svneol=native#text/pascal
tests/webtbs/uw3179a.pp svneol=native#text/plain
tests/webtbs/uw3179b.pp svneol=native#text/plain
tests/webtbs/uw3184a.pp svneol=native#text/plain

View File

@ -2949,6 +2949,13 @@ implementation
(
isspezproc and
(current_procinfo.procdef.struct=current_structdef)
) or
{ specializations may access private symbols that their
generics are allowed to access }
(
assigned(current_structdef) and
(df_specialization in current_structdef.defoptions) and
(symst.moduleid=current_structdef.genericdef.owner.moduleid)
)
);
end;
@ -3023,6 +3030,13 @@ implementation
(
isspezproc and
(current_procinfo.procdef.struct=current_structdef)
) or
{ specializations may access private symbols that their
generics are allowed to access }
(
assigned(current_structdef) and
(df_specialization in current_structdef.defoptions) and
(symst.moduleid=current_structdef.genericdef.owner.moduleid)
)
);
end;

14
tests/webtbs/tw31431.pp Normal file
View File

@ -0,0 +1,14 @@
program tw31431;
{$mode objfpc}
uses
uw31431;
type
TSpecialisedClass = specialize TBar<Integer>;
begin
end.

26
tests/webtbs/uw31431.pp Normal file
View File

@ -0,0 +1,26 @@
unit uw31431;
{$mode objfpc}
interface
type
TFoo = class
private
type
TID = Integer;
protected
type
TID2 = Integer;
end;
generic TBar<T> = class
private
FID: TFoo.TID;
FID2: TFoo.TID2;
end;
implementation
end.