diff --git a/mypy/semanal.py b/mypy/semanal.py index 7f0c1954b46d..50e3d8cc6c68 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -1227,7 +1227,8 @@ class Foo(Bar, Generic[T]): ... if declared_tvars: self.fail('Only single Generic[...] or Protocol[...] can be in bases', context) removed.append(i) - tvars, is_protocol = result + tvars = result[0] + is_protocol |= result[1] declared_tvars.extend(tvars) if isinstance(base, UnboundType): sym = self.lookup_qualified(base.name, base) diff --git a/test-data/unit/check-semanal-error.test b/test-data/unit/check-semanal-error.test index 3bde5faab286..af794a287ad9 100644 --- a/test-data/unit/check-semanal-error.test +++ b/test-data/unit/check-semanal-error.test @@ -97,3 +97,19 @@ def m() -> None: ... # E: Name 'm' already defined (possibly by an import) def f() -> None: ... # E: Name 'f' already defined (possibly by an import) [out] + +[case testRuntimeProtoTwoBases] +from typing_extensions import Protocol, runtime_checkable +from typing import TypeVar, Generic + +T = TypeVar('T') + +@runtime_checkable +class P(Protocol, Generic[T]): + attr: T + +class C: + attr: int + +x: P[int] = C() +[out]