|
25 | 25 | from mypy.constraints import SUPERTYPE_OF
|
26 | 26 | from mypy.erasetype import erase_type, erase_typevars, remove_instance_last_known_values
|
27 | 27 | from mypy.errorcodes import TYPE_VAR, UNUSED_AWAITABLE, UNUSED_COROUTINE, ErrorCode
|
28 |
| -from mypy.errors import Errors, ErrorWatcher, LoopErrorWatcher, report_internal_error |
| 28 | +from mypy.errors import ErrorInfo, Errors, ErrorWatcher, LoopErrorWatcher, report_internal_error |
29 | 29 | from mypy.expandtype import expand_type
|
30 | 30 | from mypy.literals import Key, extract_var_from_literal_hash, literal, literal_hash
|
31 | 31 | from mypy.maptype import map_instance_to_supertype
|
@@ -7181,7 +7181,7 @@ def check_subtype(
|
7181 | 7181 | if extra_info:
|
7182 | 7182 | msg = msg.with_additional_msg(" (" + ", ".join(extra_info) + ")")
|
7183 | 7183 |
|
7184 |
| -self.fail(msg, context) |
| 7184 | +error = self.fail(msg, context) |
7185 | 7185 | for note in notes:
|
7186 | 7186 | self.msg.note(note, context, code=msg.code)
|
7187 | 7187 | if note_msg:
|
@@ -7192,7 +7192,7 @@ def check_subtype(
|
7192 | 7192 | and supertype.type.is_protocol
|
7193 | 7193 | and isinstance(subtype, (CallableType, Instance, TupleType, TypedDictType))
|
7194 | 7194 | ):
|
7195 |
| -self.msg.report_protocol_problems(subtype, supertype, context, code=msg.code) |
| 7195 | +self.msg.report_protocol_problems(subtype, supertype, context, parent_error=error) |
7196 | 7196 | if isinstance(supertype, CallableType) and isinstance(subtype, Instance):
|
7197 | 7197 | call = find_member("__call__", subtype, subtype, is_operator=True)
|
7198 | 7198 | if call:
|
@@ -7521,12 +7521,11 @@ def temp_node(self, t: Type, context: Context | None = None) -> TempNode:
|
7521 | 7521 |
|
7522 | 7522 | def fail(
|
7523 | 7523 | self, msg: str | ErrorMessage, context: Context, *, code: ErrorCode | None = None
|
7524 |
| -) -> None: |
| 7524 | +) -> ErrorInfo: |
7525 | 7525 | """Produce an error message."""
|
7526 | 7526 | if isinstance(msg, ErrorMessage):
|
7527 |
| -self.msg.fail(msg.value, context, code=msg.code) |
7528 |
| -return |
7529 |
| -self.msg.fail(msg, context, code=code) |
| 7527 | +return self.msg.fail(msg.value, context, code=msg.code) |
| 7528 | +return self.msg.fail(msg, context, code=code) |
7530 | 7529 |
|
7531 | 7530 | def note(
|
7532 | 7531 | self,
|
|
0 commit comments