@@ -186,7 +186,7 @@ class ExpandTypeVisitor(TrivialSyntheticTypeTranslator):
186
186
187
187
def __init__ (self , variables : Mapping [TypeVarId , Type ]) -> None :
188
188
self .variables = variables
189
- self .recursive_guard : set [Type ] = set ()
189
+ self .recursive_guard : set [Type | tuple [ int , Type ] ] = set ()
190
190
191
191
def visit_unbound_type (self , t : UnboundType ) -> Type :
192
192
return t
@@ -231,13 +231,11 @@ def visit_type_var(self, t: TypeVarType) -> Type:
231
231
t = t .copy_modified (upper_bound = t .upper_bound .accept (self ))
232
232
repl = self .variables .get (t .id , t )
233
233
234
- if has_type_vars (repl ) and not isinstance (repl , ( TypeVarType , Instance ) ):
235
- if repl in self .recursive_guard or isinstance (repl , ( TypeVarType , CallableType ) ):
234
+ if has_type_vars (repl ) and not isinstance (repl , Instance ):
235
+ if repl in self .recursive_guard : # or isinstance(repl, CallableType):
236
236
return repl
237
237
self .recursive_guard .add (repl )
238
238
repl = repl .accept (self )
239
- if t .has_default ():
240
- repl = t .copy_modified (default = repl )
241
239
242
240
if isinstance (repl , Instance ):
243
241
# TODO: do we really need to do this?
@@ -251,15 +249,11 @@ def visit_param_spec(self, t: ParamSpecType) -> Type:
251
249
self .variables .get (t .id , t .copy_modified (prefix = Parameters ([], [], [])))
252
250
)
253
251
254
- while True :
255
- if has_param_specs (repl ) and not isinstance (repl , (ParamSpecType , Instance )):
256
- if repl in self .recursive_guard :
257
- break
258
- self .recursive_guard .add (repl )
259
- repl = repl .accept (self )
260
- if t .has_default ():
261
- repl = t .copy_modified (default = repl )
262
- break
252
+ if has_param_specs (repl ) and not isinstance (repl , Instance ):
253
+ if (t .flavor , repl ) in self .recursive_guard :
254
+ return repl
255
+ self .recursive_guard .add ((t .flavor , repl ))
256
+ repl = repl .accept (self )
263
257
264
258
if isinstance (repl , Instance ):
265
259
# TODO: what does prefix mean in this case?
0 commit comments