From 7343e9c4a273b789577856915e0edf6613fa4b41 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Sat, 2 Jan 2021 23:23:34 +0000 Subject: [PATCH] * correctly handle the case should the generic dummy symbol be a procsym instead of a typesym git-svn-id: trunk@48001 - --- compiler/pexpr.pas | 29 +++++++++++++++++++++++------ compiler/symtable.pas | 10 ++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 8df8d235d8..a36bef1900 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -1514,9 +1514,11 @@ implementation begin if srsym.typ=typesym then spezdef:=ttypesym(srsym).typedef + else if tprocsym(srsym).procdeflist.count>0 then + spezdef:=tdef(tprocsym(srsym).procdeflist[0]) else - spezdef:=tdef(tprocsym(srsym).procdeflist[0]); - if (spezdef.typ=errordef) and (sp_generic_dummy in srsym.symoptions) then + spezdef:=nil; + if (not assigned(spezdef) or (spezdef.typ=errordef)) and (sp_generic_dummy in srsym.symoptions) then symname:=srsym.RealName else symname:=''; @@ -3048,12 +3050,20 @@ implementation wasgenericdummy:=false; if assigned(srsym) and (sp_generic_dummy in srsym.symoptions) and - (srsym.typ=typesym) and + (srsym.typ in [procsym,typesym]) and ( ( (m_delphi in current_settings.modeswitches) and not (token in [_LT, _LSHARPBRACKET]) and - (ttypesym(srsym).typedef.typ=undefineddef) + ( + ( + (srsym.typ=typesym) and + (ttypesym(srsym).typedef.typ=undefineddef) + ) or ( + (srsym.typ=procsym) and + (tprocsym(srsym).procdeflist.count=0) + ) + ) ) or ( @@ -3306,8 +3316,14 @@ implementation procsym : begin p1:=nil; + if (m_delphi in current_settings.modeswitches) and + (sp_generic_dummy in srsym.symoptions) and + (token in [_LT,_LSHARPBRACKET]) then + begin + p1:=cspecializenode.create(nil,getaddr,srsym) + end { check if it's a method/class method } - if is_member_read(srsym,srsymtable,p1,hdef) then + else if is_member_read(srsym,srsymtable,p1,hdef) then begin { if we are accessing a owner procsym from the nested } { class we need to call it as a class member } @@ -4214,7 +4230,8 @@ implementation typesym: result:=ttypesym(sym).typedef; procsym: - result:=tdef(tprocsym(sym).procdeflist[0]); + if not (sp_generic_dummy in sym.symoptions) or (tprocsym(sym).procdeflist.count>0) then + result:=tdef(tprocsym(sym).procdeflist[0]); else internalerror(2015092701); end; diff --git a/compiler/symtable.pas b/compiler/symtable.pas index 731b5028e5..8117af72f7 100644 --- a/compiler/symtable.pas +++ b/compiler/symtable.pas @@ -3374,6 +3374,8 @@ implementation exit; end; end; + if (tprocsym(sym).procdeflist.count=0) and (sp_generic_dummy in tprocsym(sym).symoptions) then + result:=is_visible_for_object(sym.owner,sym.visibility,contextobjdef); end else result:=is_visible_for_object(sym.owner,sym.visibility,contextobjdef); @@ -4254,6 +4256,14 @@ implementation result:=true; exit; end; + if (sp_generic_dummy in tprocsym(srsym).symoptions) and + (tprocsym(srsym).procdeflist.count=0) and + is_visible_for_object(srsym.owner,srsym.visibility,contextclassh) then + begin + srsymtable:=srsym.owner; + result:=true; + exit; + end; end; typesym, fieldvarsym,