diff --git a/mypy/join.py b/mypy/join.py index ac01d11d11d6..fcfc6cbaa0e7 100644 --- a/mypy/join.py +++ b/mypy/join.py @@ -635,6 +635,8 @@ def default(self, typ: Type) -> ProperType: typ = get_proper_type(typ) if isinstance(typ, Instance): return object_from_instance(typ) + elif isinstance(typ, TypeType): + return self.default(typ.item) elif isinstance(typ, UnboundType): return AnyType(TypeOfAny.special_form) elif isinstance(typ, TupleType): diff --git a/mypy/test/testtypes.py b/mypy/test/testtypes.py index a42519c64956..63d8840fa217 100644 --- a/mypy/test/testtypes.py +++ b/mypy/test/testtypes.py @@ -1064,6 +1064,10 @@ def test_variadic_tuple_joins(self) -> None: self.tuple(UnpackType(Instance(self.fx.std_tuplei, [self.fx.a])), self.fx.a), ) + def test_join_type_type_type_var(self) -> None: + self.assert_join(self.fx.type_a, self.fx.t, self.fx.o) + self.assert_join(self.fx.t, self.fx.type_a, self.fx.o) + # There are additional test cases in check-inference.test. # TODO: Function types + varargs and default args.