diff --git a/.gitattributes b/.gitattributes
index 7f9cb22a13..7d128b44ed 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -14758,6 +14758,7 @@ tests/webtbs/tw28718b.pp svneol=native#text/plain
 tests/webtbs/tw28718c.pp svneol=native#text/plain
 tests/webtbs/tw28718d.pp svneol=native#text/plain
 tests/webtbs/tw2876.pp svneol=native#text/plain
+tests/webtbs/tw28766.pp svneol=native#text/pascal
 tests/webtbs/tw2883.pp svneol=native#text/plain
 tests/webtbs/tw2885.pp svneol=native#text/plain
 tests/webtbs/tw2886.pp svneol=native#text/plain
@@ -15468,6 +15469,7 @@ tests/webtbs/uw27320.defaults.pp svneol=native#text/pascal
 tests/webtbs/uw2738.pp svneol=native#text/plain
 tests/webtbs/uw2834.pp svneol=native#text/plain
 tests/webtbs/uw28442.pp svneol=native#text/pascal
+tests/webtbs/uw28766.pp svneol=native#text/pascal
 tests/webtbs/uw2920.pp svneol=native#text/plain
 tests/webtbs/uw2956.pp svneol=native#text/plain
 tests/webtbs/uw2984.pp svneol=native#text/plain
diff --git a/compiler/ncgrtti.pas b/compiler/ncgrtti.pas
index 70ceb5f7ac..27ea028795 100644
--- a/compiler/ncgrtti.pas
+++ b/compiler/ncgrtti.pas
@@ -109,14 +109,16 @@ implementation
         for i:=0 to st.DefList.Count-1 do
           begin
             def:=tdef(st.DefList[i]);
+            { skip generics }
+            if [df_generic,df_genconstraint]*def.defoptions<>[] then
+              continue;
             case def.typ of
               recorddef:
                 write_persistent_type_info(trecorddef(def).symtable,is_global);
               objectdef :
                 begin
-                  { Skip generics and forward defs }
-                  if ([df_generic,df_genconstraint]*def.defoptions<>[]) or
-                     (oo_is_forward in tobjectdef(def).objectoptions) then
+                  { Skip forward defs }
+                  if (oo_is_forward in tobjectdef(def).objectoptions) then
                     continue;
                   write_persistent_type_info(tobjectdef(def).symtable,is_global);
                 end;
diff --git a/tests/webtbs/tw28766.pp b/tests/webtbs/tw28766.pp
new file mode 100644
index 0000000000..905e14f729
--- /dev/null
+++ b/tests/webtbs/tw28766.pp
@@ -0,0 +1,9 @@
+{ %NORUN }
+
+program tw28766;
+
+uses
+  uw28766;
+
+begin
+end.
diff --git a/tests/webtbs/uw28766.pp b/tests/webtbs/uw28766.pp
new file mode 100644
index 0000000000..237be1f756
--- /dev/null
+++ b/tests/webtbs/uw28766.pp
@@ -0,0 +1,13 @@
+unit uw28766;
+
+{$mode delphi}
+
+interface
+
+type
+  TSimpleGeneric<A, B> = function(constref Value: A): B;
+
+implementation
+
+end.
+