Pārlūkot izejas kodu

* special detection of an ongoing specialization for the case that a function that belongs to a generic and has said generic as parameter or result is in turn specialized as a parameter or result of another generic function

git-svn-id: trunk@34412 -
svenbarth 9 gadi atpakaļ
vecāks
revīzija
80c2e3b51a
1 mainītis faili ar 25 papildinājumiem un 1 dzēšanām
  1. 25 1
      compiler/pgenutil.pas

+ 25 - 1
compiler/pgenutil.pas

@@ -702,6 +702,7 @@ uses
         i,
         replaydepth : longint;
         item : tobject;
+        allequal,
         hintsprocessed : boolean;
         pd : tprocdef;
         pdflags : tpdflags;
@@ -782,11 +783,34 @@ uses
             def:=current_genericdef;
             while assigned(def) and (def.typ in [recorddef,objectdef]) do
               begin
-                if def=genericdef then
+                if (df_generic in def.defoptions) and (def=genericdef) then
                   begin
                     result:=def;
                     break;
                   end;
+                { the following happens when a routine with its parent struct
+                  as parameter is specialized as a parameter or result of a
+                  generic function }
+                if (df_specialization in def.defoptions) and (tstoreddef(def).genericdef=genericdef) then
+                  begin
+                    if tstoreddef(def).genericparas.count=generictypelist.count then
+                      begin
+                        allequal:=true;
+                        for i:=0 to generictypelist.count-1 do
+                          begin
+                            if not equal_defs(ttypesym(generictypelist[i]).typedef,ttypesym(tstoreddef(def).genericparas[i]).typedef) then
+                              begin
+                                allequal:=false;
+                                break;
+                              end;
+                          end;
+                        if allequal then
+                          begin
+                            result:=def;
+                            break;
+                          end;
+                      end;
+                  end;
                 def:=tstoreddef(def.owner.defowner);
               end;
           end;