File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,18 @@ def apply_generic_arguments(
147
147
# TODO: move apply_poly() logic from checkexpr.py here when new inference
148
148
# becomes universally used (i.e. in all passes + in unification).
149
149
# With this new logic we can actually *add* some new free variables.
150
- remaining_tvars = [expand_type (tv , id_to_type ) for tv in tvars if tv .id not in id_to_type ]
150
+ remaining_tvars : list [TypeVarLikeType ] = []
151
+ for tv in tvars :
152
+ if tv .id in id_to_type :
153
+ continue
154
+ if not tv .has_default ():
155
+ remaining_tvars .append (tv )
156
+ continue
157
+ # TypeVarLike isn't in id_to_type mapping.
158
+ # Only expand the TypeVar default here.
159
+ typ = expand_type (tv , id_to_type )
160
+ assert isinstance (typ , TypeVarLikeType )
161
+ remaining_tvars .append (typ )
151
162
152
163
return callable .copy_modified (
153
164
ret_type = expand_type (callable .ret_type , id_to_type ),
Original file line number Diff line number Diff line change @@ -1954,13 +1954,14 @@ class Foo(Bar, Generic[T]): ...
1954
1954
del base_type_exprs [i ]
1955
1955
tvar_defs : list [TypeVarLikeType ] = []
1956
1956
for name , tvar_expr in declared_tvars :
1957
- if isinstance (tvar_expr .default , UnboundType ):
1957
+ tvar_expr_default = tvar_expr .default
1958
+ if isinstance (tvar_expr_default , UnboundType ):
1958
1959
# Assumption here is that the names cannot be duplicated
1959
1960
# TODO: - detect out of order and self-referencing typevars
1960
1961
# - nested default types, e.g. list[T1]
1961
1962
for fullname , type_var in self .tvar_scope .scope .items ():
1962
1963
type_var_name = fullname .rpartition ("." )[2 ]
1963
- if tvar_expr . default .name == type_var_name :
1964
+ if tvar_expr_default .name == type_var_name :
1964
1965
tvar_expr .default = type_var
1965
1966
tvar_def = self .tvar_scope .bind_new (name , tvar_expr )
1966
1967
tvar_defs .append (tvar_def )
You can’t perform that action at this time.
0 commit comments