* 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 -
This commit is contained in:
svenbarth 2020-10-12 16:55:14 +00:00
parent 2f877218b4
commit e90cf131fe
3 changed files with 45 additions and 1 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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
tests/webtbs/tw37844.pp Normal file
View File

@ -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.