diff --git a/compiler/psub.pas b/compiler/psub.pas index 5400b5a9d5..8dd7ead7a2 100644 --- a/compiler/psub.pas +++ b/compiler/psub.pas @@ -1998,6 +1998,8 @@ implementation i : longint; hp : tdef; begin + if df_methods_specialized in def.defoptions then + Exit; for i:=0 to def.symtable.DefList.Count-1 do begin hp:=tdef(def.symtable.DefList[i]); @@ -2024,6 +2026,9 @@ implementation { generate code for subtypes as well } process_abstractrecorddef(tabstractrecorddef(hp)); end; + { we need to flag the def, so that we know the next time that we + already specialized the methods } + Include(def.defoptions, df_methods_specialized); end; begin diff --git a/compiler/symconst.pas b/compiler/symconst.pas index 70172cfef8..e80ac952bc 100644 --- a/compiler/symconst.pas +++ b/compiler/symconst.pas @@ -184,7 +184,15 @@ type { type is a specialization of a generic type } df_specialization, { def has been copied from another def so symtable is not owned } - df_copied_def + df_copied_def, + { this flag is set when the methods for a spezialization where already + generated; this is for example needed in case of the enumerator in the + generic lists of fgl.pp: the enumerator is specialized as part of the + surrounding class and if the class and the enumerator are used in the + same unit the methods of the enumerator are generated twice, once as part + of the class and once as part of the temporary variable that holds the + enumerator } + df_methods_specialized ); tdefoptions=set of tdefoption;