Browse Source

* fix #41007: only unlink typesyms from their typedefs when releasing an unused implicit specialization if the typesym was created for the implicit specialization
+ added test

Sven/Sarah Barth 7 months ago
parent
commit
79ff74ac44
3 changed files with 41 additions and 1 deletions
  1. 1 1
      compiler/pgenutil.pas
  2. 23 0
      tests/webtbs/tw41007.pp
  3. 17 0
      tests/webtbs/uw41007.pp

+ 1 - 1
compiler/pgenutil.pas

@@ -1335,7 +1335,7 @@ uses
           begin
           begin
             for k:=0 to callerparams.count-1 do
             for k:=0 to callerparams.count-1 do
               begin
               begin
-                if tsym(callerparams[k]).typ=typesym then
+                if (tsym(callerparams[k]).typ=typesym) and (sp_generic_unnamed_type in ttypesym(callerparams[k]).symoptions) then
                   ttypesym(callerparams[k]).typedef.typesym:=nil;
                   ttypesym(callerparams[k]).typedef.typesym:=nil;
               end;
               end;
           end;
           end;

+ 23 - 0
tests/webtbs/tw41007.pp

@@ -0,0 +1,23 @@
+{ %NORUN }
+
+program tw41007;
+
+{$mode delphi}
+{$modeswitch implicitfunctionspecialization}
+
+uses
+  uw41007;
+
+  procedure Test(A: string; B: string); overload;
+  begin
+  end;
+
+  procedure Test<T>; overload;
+  begin
+
+  end;
+
+begin
+  Test('aa', 'bb');
+end.
+

+ 17 - 0
tests/webtbs/uw41007.pp

@@ -0,0 +1,17 @@
+unit uw41007;
+
+{$mode delphi}
+
+interface
+
+procedure Test<T>(A: T); overload;
+
+implementation
+
+procedure Test<T>(A: T);
+begin
+
+end;
+
+end.
+