Allow dynamic creation of generic dataclasses (GH-6319)

diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index bd7252c..04e07f8 100644
--- a/Lib/dataclasses.py
+++ b/Lib/dataclasses.py
@@ -1004,7 +1004,9 @@
         anns[name] = tp
 
     namespace['__annotations__'] = anns
-    cls = type(cls_name, bases, namespace)
+    # We use `types.new_class()` instead of simply `type()` to allow dynamic creation
+    # of generic dataclassses.
+    cls = types.new_class(cls_name, bases, {}, lambda ns: ns.update(namespace))
     return dataclass(cls, init=init, repr=repr, eq=eq, order=order,
                      unsafe_hash=unsafe_hash, frozen=frozen)