Fix issue #24635.
diff --git a/Lib/typing.py b/Lib/typing.py
index ddaec3e..1a4982e 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -1,7 +1,3 @@
-# TODO:
-# - Generic[T, T] is invalid
-# - Look for TODO below
-
 # TODO nits:
 # Get rid of asserts that are the caller's fault.
 # Docstrings (e.g. ABCs).
@@ -963,7 +959,8 @@
                     raise TypeError("Initial parameters must be "
                                     "type variables; got %s" % p)
             if len(set(params)) != len(params):
-                raise TypeError("All type variables in Generic[...] must be distinct.")
+                raise TypeError(
+                    "All type variables in Generic[...] must be distinct.")
         else:
             if len(params) != len(self.__parameters__):
                 raise TypeError("Cannot change parameter count from %d to %d" %
@@ -987,6 +984,14 @@
                               origin=self,
                               extra=self.__extra__)
 
+    def __instancecheck__(self, instance):
+        # Since we extend ABC.__subclasscheck__ and
+        # ABC.__instancecheck__ inlines the cache checking done by the
+        # latter, we must extend __instancecheck__ too. For simplicity
+        # we just skip the cache check -- instance checks for generic
+        # classes are supposed to be rare anyways.
+        return self.__subclasscheck__(instance.__class__)
+
     def __subclasscheck__(self, cls):
         if cls is Any:
             return True