Răsfoiți Sursa

* correctly handle unit identifiers inside specializations of generic routines

git-svn-id: trunk@37080 -
svenbarth 8 ani în urmă
părinte
comite
83e4585b0f
4 a modificat fișierele cu 45 adăugiri și 1 ștergeri
  1. 2 0
      .gitattributes
  2. 6 1
      compiler/symtable.pas
  3. 14 0
      tests/tbs/tb0629.pp
  4. 23 0
      tests/tbs/ub0629.pp

+ 2 - 0
.gitattributes

@@ -11375,6 +11375,7 @@ tests/tbs/tb0627.pp svneol=native#text/pascal
 tests/tbs/tb0627a.pp svneol=native#text/pascal
 tests/tbs/tb0627b.pp svneol=native#text/pascal
 tests/tbs/tb0628.pp svneol=native#text/pascal
+tests/tbs/tb0629.pp svneol=native#text/pascal
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/tb610.pp svneol=native#text/pascal
 tests/tbs/tb613.pp svneol=native#text/plain
@@ -11414,6 +11415,7 @@ tests/tbs/ub0489.pp svneol=native#text/plain
 tests/tbs/ub0489b.pp svneol=native#text/plain
 tests/tbs/ub0506.pp svneol=native#text/plain
 tests/tbs/ub0569.pp svneol=native#text/pascal
+tests/tbs/ub0629.pp svneol=native#text/pascal
 tests/test/README.txt svneol=native#text/plain
 tests/test/alglib/t_testconvunit.pp svneol=native#text/plain
 tests/test/alglib/t_testcorrunit.pp svneol=native#text/plain

+ 6 - 1
compiler/symtable.pas

@@ -3135,7 +3135,12 @@ implementation
                    (
                      not(srsym.typ in [unitsym,namespacesym]) or
                      srsymtable.iscurrentunit or
-                     (assigned(current_specializedef)and(current_specializedef.genericdef.owner.moduleid=srsymtable.moduleid))
+                     (assigned(current_specializedef)and(current_specializedef.genericdef.owner.moduleid=srsymtable.moduleid)) or
+                     (
+                       assigned(current_procinfo) and
+                       (df_specialization in current_procinfo.procdef.defoptions) and
+                       (current_procinfo.procdef.genericdef.owner.moduleid=srsymtable.moduleid)
+                     )
                    ) and
                    (not (ssf_search_option in flags) or (option in srsym.symoptions))then
                   begin

+ 14 - 0
tests/tbs/tb0629.pp

@@ -0,0 +1,14 @@
+{ %NORUN }
+
+program tb0629;
+
+{$mode objfpc}
+
+uses
+  ub0629, typinfo;
+
+var
+  ti: PTypeInfo;
+begin
+  ti := TTest.specialize GetTypeInfo<LongInt>;
+end.

+ 23 - 0
tests/tbs/ub0629.pp

@@ -0,0 +1,23 @@
+unit ub0629;
+
+{$mode objfpc}
+{$modeswitch advancedrecords}
+
+interface
+
+uses
+  typinfo;
+
+type
+  TTest = record
+    generic class function GetTypeInfo<T>: PTypeInfo; static;
+  end;
+
+implementation
+
+generic class function TTest.GetTypeInfo<T>: PTypeInfo;
+begin
+  Result := System.TypeInfo(T);
+end;
+
+end.