diff --git a/gobject/gtype.h b/gobject/gtype.h
index e2b3c70..d38f374 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1464,9 +1464,9 @@ G_GNUC_INTERNAL void    g_signal_init           (void); /* sync with gsignal.c *
 /* --- implementation bits --- */
 #ifndef G_DISABLE_CAST_CHECKS
 #  define _G_TYPE_CIC(ip, gt, ct) \
-    ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt))
+    (_G_TYPE_CIT (ip, gt) ? (ct*) ip : (ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt))
 #  define _G_TYPE_CCC(cp, gt, ct) \
-    ((ct*) g_type_check_class_cast ((GTypeClass*) cp, gt))
+    (_G_TYPE_CCT (cp, gt) ? (ct*) cp : (ct*) g_type_check_class_cast ((GTypeClass*) cp, gt))
 #else /* G_DISABLE_CAST_CHECKS */
 #  define _G_TYPE_CIC(ip, gt, ct)       ((ct*) ip)
 #  define _G_TYPE_CCC(cp, gt, ct)       ((ct*) cp)
