瀏覽代碼

Fix for Mantis #26749 .

pgenutil.pas, generate_specialization:
  * first check whether we can reuse the current specialization or another specialization and only /then/ retrieve the symtable to specialize to

+ added test

git-svn-id: trunk@28705 -
svenbarth 11 年之前
父節點
當前提交
16774350d7
共有 3 個文件被更改,包括 61 次插入33 次删除
  1. 1 0
      .gitattributes
  2. 33 33
      compiler/pgenutil.pas
  3. 27 0
      tests/webtbs/tw26749.pp

+ 1 - 0
.gitattributes

@@ -14088,6 +14088,7 @@ tests/webtbs/tw26627.pp -text svneol=native#text/plain
 tests/webtbs/tw2666.pp svneol=native#text/plain
 tests/webtbs/tw2666.pp svneol=native#text/plain
 tests/webtbs/tw2668.pp svneol=native#text/plain
 tests/webtbs/tw2668.pp svneol=native#text/plain
 tests/webtbs/tw2669.pp svneol=native#text/plain
 tests/webtbs/tw2669.pp svneol=native#text/plain
+tests/webtbs/tw26749.pp svneol=native#text/pascal
 tests/webtbs/tw2676.pp svneol=native#text/plain
 tests/webtbs/tw2676.pp svneol=native#text/plain
 tests/webtbs/tw2678.pp svneol=native#text/plain
 tests/webtbs/tw2678.pp svneol=native#text/plain
 tests/webtbs/tw2690.pp svneol=native#text/plain
 tests/webtbs/tw2690.pp svneol=native#text/plain

+ 33 - 33
compiler/pgenutil.pas

@@ -689,39 +689,6 @@ uses
            (current_structdef.objname^=ufinalspecializename) then
            (current_structdef.objname^=ufinalspecializename) then
           tt:=current_structdef;
           tt:=current_structdef;
 
 
-        { decide in which symtable to put the specialization }
-        if parse_generic then
-          begin
-            if not assigned(current_genericdef) then
-              internalerror(2014050901);
-            if assigned(current_procinfo) and (df_generic in current_procinfo.procdef.defoptions) then
-              { if we are parsing the definition of a method we specialize into
-                the local symtable of it }
-              specializest:=current_procinfo.procdef.getsymtable(gs_local)
-            else
-              { we specialize the partial specialization into the symtable of the currently parsed
-                generic }
-              case current_genericdef.typ of
-                procvardef,
-                procdef:
-                  specializest:=current_genericdef.getsymtable(gs_local);
-                objectdef,
-                recorddef:
-                  specializest:=current_genericdef.getsymtable(gs_record);
-                arraydef:
-                  specializest:=tarraydef(current_genericdef).symtable;
-                else
-                  internalerror(2014050902);
-              end;
-          end
-        else
-          if current_module.is_unit and current_module.in_interface then
-            specializest:=current_module.globalsymtable
-          else
-            specializest:=current_module.localsymtable;
-        if not assigned(specializest) then
-          internalerror(2014050910);
-
         { Can we reuse an already specialized type? }
         { Can we reuse an already specialized type? }
 
 
         { for this first check whether we are currently specializing a nested
         { for this first check whether we are currently specializing a nested
@@ -759,6 +726,39 @@ uses
               end;
               end;
           end;
           end;
 
 
+        { decide in which symtable to put the specialization }
+        if parse_generic and not assigned(tt) then
+          begin
+            if not assigned(current_genericdef) then
+              internalerror(2014050901);
+            if assigned(current_procinfo) and (df_generic in current_procinfo.procdef.defoptions) then
+              { if we are parsing the definition of a method we specialize into
+                the local symtable of it }
+              specializest:=current_procinfo.procdef.getsymtable(gs_local)
+            else
+              { we specialize the partial specialization into the symtable of the currently parsed
+                generic }
+              case current_genericdef.typ of
+                procvardef,
+                procdef:
+                  specializest:=current_genericdef.getsymtable(gs_local);
+                objectdef,
+                recorddef:
+                  specializest:=current_genericdef.getsymtable(gs_record);
+                arraydef:
+                  specializest:=tarraydef(current_genericdef).symtable;
+                else
+                  internalerror(2014050902);
+              end;
+          end
+        else
+          if current_module.is_unit and current_module.in_interface then
+            specializest:=current_module.globalsymtable
+          else
+            specializest:=current_module.localsymtable;
+        if not assigned(specializest) then
+          internalerror(2014050910);
+
         { now check whether there is a specialization somewhere else }
         { now check whether there is a specialization somewhere else }
         if not assigned(tt) then
         if not assigned(tt) then
           begin
           begin

+ 27 - 0
tests/webtbs/tw26749.pp

@@ -0,0 +1,27 @@
+{ %NORUN }
+
+program tw26749;
+
+{$mode delphi}
+{$modeswitch advancedrecords}
+
+type
+
+	{ TVector3 }
+
+  TVector3<T> = record
+    class function null : TVector3<T>; static;
+  end;
+
+  TLine<T> = array[0..1] of TVector3<T>;
+
+{ TVector3<T> }
+
+class function TVector3<T>.null : TVector3<T>;
+begin
+
+end;
+
+begin
+end.
+