(self, t: Instance)
| 342 | return self.default(self.s) |
| 343 | |
| 344 | def visit_instance(self, t: Instance) -> ProperType: |
| 345 | if isinstance(self.s, Instance): |
| 346 | if self.instance_joiner is None: |
| 347 | self.instance_joiner = InstanceJoiner() |
| 348 | nominal = self.instance_joiner.join_instances(t, self.s) |
| 349 | structural: Instance | None = None |
| 350 | if t.type.is_protocol and is_protocol_implementation(self.s, t): |
| 351 | structural = t |
| 352 | elif self.s.type.is_protocol and is_protocol_implementation(t, self.s): |
| 353 | structural = self.s |
| 354 | # Structural join is preferred in the case where we have found both |
| 355 | # structural and nominal and they have same MRO length (see two comments |
| 356 | # in join_instances_via_supertype). Otherwise, just return the nominal join. |
| 357 | if not structural or is_better(nominal, structural): |
| 358 | return nominal |
| 359 | return structural |
| 360 | elif isinstance(self.s, FunctionLike): |
| 361 | if t.type.is_protocol: |
| 362 | call = unpack_callback_protocol(t) |
| 363 | if call: |
| 364 | return join_types(call, self.s) |
| 365 | return join_types(t, self.s.fallback) |
| 366 | elif isinstance(self.s, TypeType): |
| 367 | return join_types(t, self.s) |
| 368 | elif isinstance(self.s, TypedDictType): |
| 369 | return join_types(t, self.s) |
| 370 | elif isinstance(self.s, TupleType): |
| 371 | return join_types(t, self.s) |
| 372 | elif isinstance(self.s, LiteralType): |
| 373 | return join_types(t, self.s) |
| 374 | elif isinstance(self.s, TypeVarTupleType) and is_subtype(self.s.upper_bound, t): |
| 375 | return t |
| 376 | else: |
| 377 | return self.default(self.s) |
| 378 | |
| 379 | def visit_callable_type(self, t: CallableType) -> ProperType: |
| 380 | if isinstance(self.s, CallableType): |
nothing calls this directly
no test coverage detected