@@ -322,7 +322,10 @@ impl CallableParams {
322322 }
323323
324324 pub fn has_any ( & self , db : & Database ) -> bool {
325- matches ! ( self , CallableParams :: Any ( _) ) || self . find_in_type ( db, & mut |t| t. has_any ( db) )
325+ match self {
326+ Self :: Simple ( params) => any_for_each_type_like ( params, |t| t. has_any ( db) ) ,
327+ Self :: Any ( _) => true ,
328+ }
326329 }
327330
328331 pub fn maybe_param_spec ( & self ) -> Option < & ParamSpecUsage > {
@@ -365,24 +368,32 @@ impl CallableParams {
365368
366369 pub fn find_in_type ( & self , db : & Database , check : & mut impl FnMut ( & Type ) -> bool ) -> bool {
367370 match self {
368- Self :: Simple ( params) => params. iter ( ) . any ( |param| match & param. type_ {
369- ParamType :: PositionalOnly ( t)
370- | ParamType :: PositionalOrKeyword ( t)
371- | ParamType :: KeywordOnly ( t)
372- | ParamType :: Star ( StarParamType :: ArbitraryLen ( t) )
373- | ParamType :: StarStar ( StarStarParamType :: ValueType ( t) ) => t. find_in_type ( db, check) ,
374- ParamType :: Star ( StarParamType :: ParamSpecArgs ( _) ) => false ,
375- ParamType :: Star ( StarParamType :: UnpackedTuple ( u) ) => u. args . find_in_type ( db, check) ,
376- ParamType :: StarStar ( StarStarParamType :: ParamSpecKwargs ( _) ) => false ,
377- ParamType :: StarStar ( StarStarParamType :: UnpackTypedDict ( td) ) => {
378- Type :: TypedDict ( td. clone ( ) ) . find_in_type ( db, check)
379- }
380- } ) ,
371+ Self :: Simple ( params) => any_for_each_type_like ( params, |t| t. find_in_type ( db, check) ) ,
381372 Self :: Any ( _) => false ,
382373 }
383374 }
384375}
385376
377+ // This probably shouldn't be used too much, it's just a helper function
378+ fn any_for_each_type_like < ' x > (
379+ params : & ' x Arc < [ CallableParam ] > ,
380+ mut callback : impl FnMut ( & Type ) -> bool ,
381+ ) -> bool {
382+ params. into_iter ( ) . any ( |param| match & param. type_ {
383+ ParamType :: PositionalOnly ( t)
384+ | ParamType :: PositionalOrKeyword ( t)
385+ | ParamType :: KeywordOnly ( t)
386+ | ParamType :: Star ( StarParamType :: ArbitraryLen ( t) )
387+ | ParamType :: StarStar ( StarStarParamType :: ValueType ( t) ) => callback ( t) ,
388+ ParamType :: Star ( StarParamType :: ParamSpecArgs ( _) ) => false ,
389+ ParamType :: Star ( StarParamType :: UnpackedTuple ( u) ) => callback ( & Type :: Tuple ( u. clone ( ) ) ) ,
390+ ParamType :: StarStar ( StarStarParamType :: ParamSpecKwargs ( _) ) => false ,
391+ ParamType :: StarStar ( StarStarParamType :: UnpackTypedDict ( td) ) => {
392+ callback ( & Type :: TypedDict ( td. clone ( ) ) )
393+ }
394+ } )
395+ }
396+
386397#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
387398pub ( crate ) struct CallableContent {
388399 pub name : Option < DbString > ,
0 commit comments