浏览代码

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

git-svn-id: trunk@35510 -
svenbarth 8 年之前
父节点
当前提交
7dc4f16db3
共有 4 个文件被更改,包括 56 次插入0 次删除
  1. 2 0
      .gitattributes
  2. 14 0
      compiler/symtable.pas
  3. 14 0
      tests/webtbs/tw31431.pp
  4. 26 0
      tests/webtbs/uw31431.pp

+ 2 - 0
.gitattributes

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

+ 14 - 0
compiler/symtable.pas

@@ -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 - 0
tests/webtbs/tw31431.pp

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

+ 26 - 0
tests/webtbs/uw31431.pp

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