diff --git a/compiler/pgentype.pas b/compiler/pgentype.pas
index 5a0e9a3915..9c01cba88b 100644
--- a/compiler/pgentype.pas
+++ b/compiler/pgentype.pas
@@ -36,10 +36,11 @@ const
 type
   pspecializationstate = ^tspecializationstate;
   tspecializationstate = record
-    oldsymtablestack    : tsymtablestack;
-    oldextendeddefs     : tfphashobjectlist;
-    oldgenericdummysyms : tfphashobjectlist;
-    oldspecializestate  : pspecializationstate;
+    oldsymtablestack      : tsymtablestack;
+    oldextendeddefs       : tfphashobjectlist;
+    oldgenericdummysyms   : tfphashobjectlist;
+    oldspecializestate    : pspecializationstate;
+    oldcurrent_genericdef : tdef;
   end;
 
   tspecializationcontext=class
diff --git a/compiler/pgenutil.pas b/compiler/pgenutil.pas
index 102dee4020..10f68c3928 100644
--- a/compiler/pgenutil.pas
+++ b/compiler/pgenutil.pas
@@ -2740,6 +2740,7 @@ uses
       state.oldsymtablestack:=symtablestack;
       state.oldextendeddefs:=current_module.extendeddefs;
       state.oldgenericdummysyms:=current_module.genericdummysyms;
+      state.oldcurrent_genericdef:=current_genericdef;
       state.oldspecializestate:=pspecializationstate(current_module.specializestate);
       current_module.specializestate:=@state;
       current_module.extendeddefs:=TFPHashObjectList.create(true);