mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-10 14:26:00 +02:00
Fix for Mantis #26749 .
pgenutil.pas, generate_specialization: * first check whether we can reuse the current specialization or another specialization and only /then/ retrieve the symtable to specialize to + added test git-svn-id: trunk@28705 -
This commit is contained in:
parent
e7eb77a94a
commit
16774350d7
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -14088,6 +14088,7 @@ tests/webtbs/tw26627.pp -text svneol=native#text/plain
|
||||
tests/webtbs/tw2666.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2668.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2669.pp svneol=native#text/plain
|
||||
tests/webtbs/tw26749.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw2676.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2678.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2690.pp svneol=native#text/plain
|
||||
|
@ -689,39 +689,6 @@ uses
|
||||
(current_structdef.objname^=ufinalspecializename) then
|
||||
tt:=current_structdef;
|
||||
|
||||
{ decide in which symtable to put the specialization }
|
||||
if parse_generic then
|
||||
begin
|
||||
if not assigned(current_genericdef) then
|
||||
internalerror(2014050901);
|
||||
if assigned(current_procinfo) and (df_generic in current_procinfo.procdef.defoptions) then
|
||||
{ if we are parsing the definition of a method we specialize into
|
||||
the local symtable of it }
|
||||
specializest:=current_procinfo.procdef.getsymtable(gs_local)
|
||||
else
|
||||
{ we specialize the partial specialization into the symtable of the currently parsed
|
||||
generic }
|
||||
case current_genericdef.typ of
|
||||
procvardef,
|
||||
procdef:
|
||||
specializest:=current_genericdef.getsymtable(gs_local);
|
||||
objectdef,
|
||||
recorddef:
|
||||
specializest:=current_genericdef.getsymtable(gs_record);
|
||||
arraydef:
|
||||
specializest:=tarraydef(current_genericdef).symtable;
|
||||
else
|
||||
internalerror(2014050902);
|
||||
end;
|
||||
end
|
||||
else
|
||||
if current_module.is_unit and current_module.in_interface then
|
||||
specializest:=current_module.globalsymtable
|
||||
else
|
||||
specializest:=current_module.localsymtable;
|
||||
if not assigned(specializest) then
|
||||
internalerror(2014050910);
|
||||
|
||||
{ Can we reuse an already specialized type? }
|
||||
|
||||
{ for this first check whether we are currently specializing a nested
|
||||
@ -759,6 +726,39 @@ uses
|
||||
end;
|
||||
end;
|
||||
|
||||
{ decide in which symtable to put the specialization }
|
||||
if parse_generic and not assigned(tt) then
|
||||
begin
|
||||
if not assigned(current_genericdef) then
|
||||
internalerror(2014050901);
|
||||
if assigned(current_procinfo) and (df_generic in current_procinfo.procdef.defoptions) then
|
||||
{ if we are parsing the definition of a method we specialize into
|
||||
the local symtable of it }
|
||||
specializest:=current_procinfo.procdef.getsymtable(gs_local)
|
||||
else
|
||||
{ we specialize the partial specialization into the symtable of the currently parsed
|
||||
generic }
|
||||
case current_genericdef.typ of
|
||||
procvardef,
|
||||
procdef:
|
||||
specializest:=current_genericdef.getsymtable(gs_local);
|
||||
objectdef,
|
||||
recorddef:
|
||||
specializest:=current_genericdef.getsymtable(gs_record);
|
||||
arraydef:
|
||||
specializest:=tarraydef(current_genericdef).symtable;
|
||||
else
|
||||
internalerror(2014050902);
|
||||
end;
|
||||
end
|
||||
else
|
||||
if current_module.is_unit and current_module.in_interface then
|
||||
specializest:=current_module.globalsymtable
|
||||
else
|
||||
specializest:=current_module.localsymtable;
|
||||
if not assigned(specializest) then
|
||||
internalerror(2014050910);
|
||||
|
||||
{ now check whether there is a specialization somewhere else }
|
||||
if not assigned(tt) then
|
||||
begin
|
||||
|
27
tests/webtbs/tw26749.pp
Normal file
27
tests/webtbs/tw26749.pp
Normal file
@ -0,0 +1,27 @@
|
||||
{ %NORUN }
|
||||
|
||||
program tw26749;
|
||||
|
||||
{$mode delphi}
|
||||
{$modeswitch advancedrecords}
|
||||
|
||||
type
|
||||
|
||||
{ TVector3 }
|
||||
|
||||
TVector3<T> = record
|
||||
class function null : TVector3<T>; static;
|
||||
end;
|
||||
|
||||
TLine<T> = array[0..1] of TVector3<T>;
|
||||
|
||||
{ TVector3<T> }
|
||||
|
||||
class function TVector3<T>.null : TVector3<T>;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user