Browse Source

* the index of the generic type parameter is not the same index of the paras list
+ added test

Sven/Sarah Barth 3 years ago
parent
commit
a5f3040da5
2 changed files with 22 additions and 1 deletions
  1. 1 1
      compiler/pgenutil.pas
  2. 21 0
      tests/test/timpfuncspez36.pp

+ 1 - 1
compiler/pgenutil.pas

@@ -972,7 +972,7 @@ uses
                   { find the generic param name in the generic def parameters }
                   { find the generic param name in the generic def parameters }
                   j:=target_proc.genericdef.genericparas.findindexof(paravar.vardef.typesym.name);
                   j:=target_proc.genericdef.genericparas.findindexof(paravar.vardef.typesym.name);
 
 
-                  target_def:=tparavarsym(target_proc.paras[j]).vardef;
+                  target_def:=ttypesym(target_proc.genericparas[j]).typedef;
                   caller_def:=caller_proc_para.vardef;
                   caller_def:=caller_proc_para.vardef;
 
 
                   if not assigned(caller_def.typesym) then
                   if not assigned(caller_def.typesym) then

+ 21 - 0
tests/test/timpfuncspez36.pp

@@ -0,0 +1,21 @@
+{ %NORUN }
+
+program timpfuncspez36;
+
+{$mode objfpc}
+{$modeswitch implicitfunctionspecialization}
+
+type
+  generic TTestFunc<T> = procedure(aArg1: String; aArg2: T);
+
+generic procedure DoTest<T>(aArg: specialize TTestFunc<T>);
+begin
+end;
+
+procedure TestFunc(aArg1: String; aArg2: LongInt);
+begin
+end;
+
+begin
+  DoTest(@TestFunc);
+end.