File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 3535 analyze_member_access ,
3636 type_object_type ,
3737)
38- from mypy .checkpattern import PatternChecker
38+ from mypy .checkpattern import PatternChecker , PatternType
3939from mypy .constraints import SUPERTYPE_OF
4040from mypy .erasetype import erase_type , erase_typevars , remove_instance_last_known_values
4141from mypy .errorcodes import TYPE_VAR , UNUSED_AWAITABLE , UNUSED_COROUTINE , ErrorCode
@@ -5296,7 +5296,13 @@ def visit_match_stmt(self, s: MatchStmt) -> None:
52965296 # capture variable may depend on multiple patterns (it
52975297 # will be a union of all capture types). This pass ignores
52985298 # guard expressions.
5299- pattern_types = [self .pattern_checker .accept (p , subject_type ) for p in s .patterns ]
5299+ pattern_types : list [PatternType ] = []
5300+ type_context = subject_type
5301+ for p in s .patterns :
5302+ pattern_type = self .pattern_checker .accept (p , type_context )
5303+ pattern_types .append (pattern_type )
5304+ type_context = get_proper_type (pattern_type .rest_type )
5305+
53005306 type_maps : list [TypeMap ] = [t .captures for t in pattern_types ]
53015307 inferred_types = self .infer_variable_types_from_type_maps (type_maps )
53025308
You can’t perform that action at this time.
0 commit comments