2
0
Эх сурвалжийг харах

* fix for Mantis #37844: prefer to use the symtable determined in generate_specialization_phase1 for procdefs as that might a withsymtable that is needed to correctly load Self later on
+ added test

git-svn-id: trunk@47101 -

svenbarth 4 жил өмнө
parent
commit
e90cf131fe

+ 1 - 0
.gitattributes

@@ -18488,6 +18488,7 @@ tests/webtbs/tw3780.pp svneol=native#text/plain
 tests/webtbs/tw37806.pp svneol=native#text/pascal
 tests/webtbs/tw3782.pp svneol=native#text/plain
 tests/webtbs/tw37823.pp svneol=native#text/pascal
+tests/webtbs/tw37844.pp svneol=native#text/pascal
 tests/webtbs/tw3796.pp svneol=native#text/plain
 tests/webtbs/tw3805.pp svneol=native#text/plain
 tests/webtbs/tw3814.pp svneol=native#text/plain

+ 4 - 1
compiler/pexpr.pas

@@ -3032,7 +3032,10 @@ implementation
                                  else
                                    begin
                                      srsym:=tprocdef(hdef).procsym;
-                                     srsymtable:=srsym.owner;
+                                     if assigned(spezcontext.symtable) then
+                                       srsymtable:=spezcontext.symtable
+                                     else
+                                       srsymtable:=srsym.owner;
                                    end;
                                end
                              else

+ 40 - 0
tests/webtbs/tw37844.pp

@@ -0,0 +1,40 @@
+program tw37844;
+{$mode objfpc}
+
+type
+    trec = record
+      value: longint;
+    end;
+    {generic grec<T> = record
+        value: T;
+    end;}
+
+    tmytype = class
+    public
+    generic function func1<T>( const v: longint ): trec;//specialize grec<T>;
+    end;
+
+generic function tmytype.func1<T>( const v: longint ): trec;//specialize grec<T>;
+begin
+    result.value := v;
+    //result.value := t(v);
+end;
+
+var
+    tmp: tmytype;
+    gr: trec;//specialize grec<string>;
+    vr: longint;//variant;
+
+begin
+    tmp := tmytype.Create;
+    vr := 123;
+    gr := Default(trec);
+    with tmp do
+        gr := specialize func1<string>( vr ); // <--!!!!!!!!!!!!!!!!!!!
+    //gr := tmp.specialize func1<string>(vr);
+    //writeln(gr.value);
+    tmp.Free;
+    if gr.value<>vr then
+      halt(1);
+    //readln;
+end.